fix: MySQL 8.0 compat for migration v358 DROP COLUMN #656
@@ -8,9 +8,17 @@ import "xorm.io/xorm"
|
||||
// DropDisplayNameColumns removes the display_name column from repo_manifest
|
||||
// and update_stream_config. Display name is now computed from extension_type + name.
|
||||
func DropDisplayNameColumns(x *xorm.Engine) error {
|
||||
if _, err := x.Exec("ALTER TABLE repo_manifest DROP COLUMN IF EXISTS display_name"); err != nil {
|
||||
return err
|
||||
// MySQL 8.0.x does not support DROP COLUMN IF EXISTS — check first.
|
||||
for _, table := range []string{"repo_manifest", "update_stream_config"} {
|
||||
var count int
|
||||
if _, err := x.SQL("SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = 'display_name'", table).Get(&count); err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
if _, err := x.Exec("ALTER TABLE `" + table + "` DROP COLUMN `display_name`"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := x.Exec("ALTER TABLE update_stream_config DROP COLUMN IF EXISTS display_name")
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user