mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-11 17:48:44 -05:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user