diff options
author | Earl Warren <contact@earl-warren.org> | 2025-01-15 23:06:38 +0100 |
---|---|---|
committer | Earl Warren <earl-warren@noreply.codeberg.org> | 2025-01-15 23:06:38 +0100 |
commit | 30038124770f959f6817921f30a5b62b42edee6d (patch) | |
tree | 399469a52aef3f6d89e5ce1bac0fa86b850ba404 | |
parent | chore(ci): upgrade forgejo-build-publish/build@v5.3.1 (#6573) (diff) | |
download | forgejo-30038124770f959f6817921f30a5b62b42edee6d.tar.xz forgejo-30038124770f959f6817921f30a5b62b42edee6d.zip |
fix: avoid Gitea migration warnings (take 2) (#6577)
274bc480b41132920e36c1cbee8a0f0e69a4ba0c introduced a regression in https://codeberg.org/forgejo/forgejo/pulls/6343
Trying to remove fields that have already been removed by
https://codeberg.org/forgejo/forgejo/src/commit/dd1523c72ee622a4d38b347668bf56003984eba0/models/forgejo_migrations/v14.go
Is a noop for SQLite and went undetected by the upgrade tests.
Fixes: https://codeberg.org/forgejo/forgejo/issues/6575
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6577
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
-rw-r--r-- | models/migrations/v1_23/v303.go | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/models/migrations/v1_23/v303.go b/models/migrations/v1_23/v303.go index c1e74c596a..e3ee180539 100644 --- a/models/migrations/v1_23/v303.go +++ b/models/migrations/v1_23/v303.go @@ -4,6 +4,8 @@ package v1_23 //nolint import ( + "fmt" + "code.gitea.io/gitea/models/migrations/base" "xorm.io/xorm" @@ -13,20 +15,26 @@ func GiteaLastDrop(x *xorm.Engine) error { sess := x.NewSession() defer sess.Close() - if err := base.DropTableColumns(sess, "badge", "slug"); err != nil { - return err - } - if err := base.DropTableColumns(sess, "oauth2_application", "skip_secondary_authorization"); err != nil { - return err - } - if err := base.DropTableColumns(sess, "repository", "default_wiki_branch"); err != nil { - return err - } - // the migration v297.go that adds everyone_access_mode exists in Gitea >= v1.22 and the column must be dropped - // but it does not exist in Forgejo and a failure to drop the column can be ignored - base.DropTableColumns(sess, "repo_unit", "everyone_access_mode") - if err := base.DropTableColumns(sess, "protected_branch", "can_force_push", "enable_force_push_allowlist", "force_push_allowlist_user_i_ds", "force_push_allowlist_team_i_ds", "force_push_allowlist_deploy_keys"); err != nil { - return err + for _, drop := range []struct { + table string + field string + }{ + {"badge", "slug"}, + {"oauth2_application", "skip_secondary_authorization"}, + {"repository", "default_wiki_branch"}, + {"repo_unit", "everyone_access_mode"}, + {"protected_branch", "can_force_push"}, + {"protected_branch", "enable_force_push_allowlist"}, + {"protected_branch", "force_push_allowlist_user_i_ds"}, + {"protected_branch", "force_push_allowlist_team_i_ds"}, + {"protected_branch", "force_push_allowlist_deploy_keys"}, + } { + if _, err := sess.Exec(fmt.Sprintf("SELECT `%s` FROM `%s` WHERE 0 = 1", drop.field, drop.table)); err != nil { + continue + } + if err := base.DropTableColumns(sess, drop.table, drop.field); err != nil { + return err + } } return sess.Commit() |