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:
kolaente
2026-02-24 13:12:42 +01:00
parent 3d6c527b64
commit 0c7c07b3b8

View File

@@ -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 {