From 4acad97688a6c837ecbc0a6f0c0fb51337ed6bfe Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 24 Feb 2026 12:49:34 +0100 Subject: [PATCH] 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 --- pkg/migration/20250317174522.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/migration/20250317174522.go b/pkg/migration/20250317174522.go index 84bbbc53b..7e9344d9b 100644 --- a/pkg/migration/20250317174522.go +++ b/pkg/migration/20250317174522.go @@ -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