From 0c7c07b3b8a573399c62577c4a22c8a31129a7e5 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 24 Feb 2026 13:12:42 +0100 Subject: [PATCH] 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. --- pkg/migration/20250317174522.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/migration/20250317174522.go b/pkg/migration/20250317174522.go index 7e9344d9b..32bb663ce 100644 --- a/pkg/migration/20250317174522.go +++ b/pkg/migration/20250317174522.go @@ -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 {