package migration import "gorm.io/gorm" // CreateMissingTables creates only schemas that are absent. Existing tables // are intentionally left untouched: GORM's MySQL column diff path can panic // when older servers return incomplete information_schema metadata, and this // project does not support implicit legacy-schema upgrades through AutoMigrate. func CreateMissingTables(db *gorm.DB, models ...any) error { missing := make([]any, 0, len(models)) for _, model := range models { if model != nil && !db.Migrator().HasTable(model) { missing = append(missing, model) } } if len(missing) == 0 { return nil } return db.Migrator().CreateTable(missing...) }