fix: make teams oidc_id rename migration idempotent

Use the shared renameColumn helper for non-SQLite databases and skip the SQLite table rebuild when oidc_id is already absent. This prevents failures after partial upgrades where the column was already renamed.

Refs #2172

Refs #2285
This commit is contained in:
kolaente
2026-02-24 12:49:34 +01:00
parent b1534f1cc8
commit 4acad97688

View File

@@ -28,6 +28,15 @@ func init() {
Description: "",
Migrate: func(tx *xorm.Engine) (err error) {
if tx.Dialect().URI().DBType == schemas.SQLITE {
var exists bool
exists, err = columnExists(tx, "teams", "oidc_id")
if err != nil {
return err
}
if !exists {
return nil
}
_, err = tx.Exec(`create table teams_dg_tmp
(
id INTEGER not null
@@ -68,8 +77,7 @@ create unique index UQE_teams_id
return
}
_, err = tx.Exec("ALTER TABLE `teams` RENAME COLUMN `oidc_id` TO `external_id`")
return
return renameColumn(tx, "teams", "oidc_id", "external_id")
},
Rollback: func(tx *xorm.Engine) error {
return nil