fix: preserve teams external_id type when renaming on mysql
Avoid using the generic renameColumn helper for this migration on MySQL because it renames columns as BIGINT. Handle the teams oidc_id -> external_id rename with a MySQL-specific CHANGE statement that keeps VARCHAR(250) and remains idempotent.
This commit is contained in:
parent
3d6c527b64
commit
0c7c07b3b8
|
|
@ -77,6 +77,28 @@ create unique index UQE_teams_id
|
|||
return
|
||||
}
|
||||
|
||||
if tx.Dialect().URI().DBType == schemas.MYSQL {
|
||||
var exists bool
|
||||
exists, err = columnExists(tx, "teams", "oidc_id")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
externalExists, err := columnExists(tx, "teams", "external_id")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if externalExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = tx.Exec("ALTER TABLE `teams` CHANGE `oidc_id` `external_id` VARCHAR(250) NULL")
|
||||
return err
|
||||
}
|
||||
|
||||
return renameColumn(tx, "teams", "oidc_id", "external_id")
|
||||
},
|
||||
Rollback: func(tx *xorm.Engine) error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue