package version_local import ( "runtime" goautomigrations "go-admin/app/goauto/migrations" "go-admin/cmd/migrate/migration" common "go-admin/common/models" "gorm.io/gorm" ) // This additive migration extends the #33 contract with the idempotency and // audit columns required by the #34 purchase task state machine. It preserves // every existing task, attempt and product row. func init() { _, fileName, _, _ := runtime.Caller(0) migration.Migrate.SetVersion(migration.GetFilename(fileName), migratePurchaseStateMachine) } func migratePurchaseStateMachine(db *gorm.DB, version string) error { return db.Transaction(func(tx *gorm.DB) error { if err := goautomigrations.Migrate(tx); err != nil { return err } return tx.Create(&common.Migration{Version: version}).Error }) }