mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 01:36:37 +08:00
[优化] 重构数据库迁移逻辑,添加版本管理和验证功能
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package migrate
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
func init() {
|
||||
Register(V11())
|
||||
}
|
||||
|
||||
func V11() Migration {
|
||||
return Migration{
|
||||
FromVersion: 10,
|
||||
ToVersion: 11,
|
||||
Migrate: migrateV11,
|
||||
Validate: validateV11,
|
||||
}
|
||||
}
|
||||
|
||||
func migrateV11(ctx Context, db *gorm.DB, backend string) error {
|
||||
return ctx.ApplyCurrentSchema(db, backend)
|
||||
}
|
||||
|
||||
func validateV11(ctx Context, db *gorm.DB, backend string) error {
|
||||
return ctx.ValidateDatabaseSchemaVersion(db, backend, 11)
|
||||
}
|
||||
Reference in New Issue
Block a user