30 lines
700 B
Go
30 lines
700 B
Go
package version
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"go-admin/app/bell/integration/event_ingress"
|
|
"go-admin/cmd/migrate/migration"
|
|
common "go-admin/common/models"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
)
|
|
|
|
func init() {
|
|
_, fileName, _, _ := runtime.Caller(0)
|
|
migration.Migrate.SetVersion(migration.GetFilename(fileName), migrateBellEventIngress)
|
|
}
|
|
|
|
func migrateBellEventIngress(db *gorm.DB, version string) error {
|
|
return db.Transaction(func(tx *gorm.DB) error {
|
|
if err := tx.AutoMigrate(
|
|
&event_ingress.ReplayToken{},
|
|
&event_ingress.EvidenceStatus{},
|
|
); err != nil {
|
|
return err
|
|
}
|
|
return tx.Clauses(clause.OnConflict{DoNothing: true}).Create(&common.Migration{Version: version}).Error
|
|
})
|
|
}
|