[功能] 实现数据库版本管理与迁移逻辑,确保数据库结构与版本一致性

This commit is contained in:
ryan
2026-03-19 16:45:22 +08:00
parent f26fcd028e
commit ae72f2da9a
5 changed files with 339 additions and 31 deletions
@@ -0,0 +1,19 @@
package model
import "time"
const (
legacyDatabaseSchemaVersion = 1
currentDatabaseSchemaVersion = 2
databaseSchemaVersionRowID = 1
)
type DatabaseSchemaVersion struct {
ID uint `json:"id" gorm:"primaryKey"`
Version int `json:"version" gorm:"not null"`
UpdatedAt time.Time `json:"updated_at"`
}
func (DatabaseSchemaVersion) TableName() string {
return "database_schema_versions"
}