mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-02-23 11:55:48 -05:00
[v10.0/forgejo] fix: avoid Gitea migration warnings (take 2) (#6578)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/6577274bc480b4
introduced a regression in https://codeberg.org/forgejo/forgejo/pulls/6343 Trying to remove fields that have already been removed bydd1523c72e/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 Co-authored-by: Earl Warren <contact@earl-warren.org> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6578 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
parent
3b7ed0cda2
commit
39843ee2b3
1 changed files with 22 additions and 14 deletions
|
@ -4,6 +4,8 @@
|
||||||
package v1_23 //nolint
|
package v1_23 //nolint
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -13,20 +15,26 @@ func GiteaLastDrop(x *xorm.Engine) error {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
|
||||||
if err := base.DropTableColumns(sess, "badge", "slug"); err != nil {
|
for _, drop := range []struct {
|
||||||
return err
|
table string
|
||||||
}
|
field string
|
||||||
if err := base.DropTableColumns(sess, "oauth2_application", "skip_secondary_authorization"); err != nil {
|
}{
|
||||||
return err
|
{"badge", "slug"},
|
||||||
}
|
{"oauth2_application", "skip_secondary_authorization"},
|
||||||
if err := base.DropTableColumns(sess, "repository", "default_wiki_branch"); err != nil {
|
{"repository", "default_wiki_branch"},
|
||||||
return err
|
{"repo_unit", "everyone_access_mode"},
|
||||||
}
|
{"protected_branch", "can_force_push"},
|
||||||
// the migration v297.go that adds everyone_access_mode exists in Gitea >= v1.22 and the column must be dropped
|
{"protected_branch", "enable_force_push_allowlist"},
|
||||||
// but it does not exist in Forgejo and a failure to drop the column can be ignored
|
{"protected_branch", "force_push_allowlist_user_i_ds"},
|
||||||
base.DropTableColumns(sess, "repo_unit", "everyone_access_mode")
|
{"protected_branch", "force_push_allowlist_team_i_ds"},
|
||||||
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 {
|
{"protected_branch", "force_push_allowlist_deploy_keys"},
|
||||||
return err
|
} {
|
||||||
|
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()
|
return sess.Commit()
|
||||||
|
|
Loading…
Add table
Reference in a new issue