mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-28 18:38:24 -05:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user