loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Earl Warren
Earl Warren
and committed by
Earl Warren
30038124 4c7bfedf

+22 -14
+22 -14
models/migrations/v1_23/v303.go
··· 4 4 package v1_23 //nolint 5 5 6 6 import ( 7 + "fmt" 8 + 7 9 "code.gitea.io/gitea/models/migrations/base" 8 10 9 11 "xorm.io/xorm" ··· 13 15 sess := x.NewSession() 14 16 defer sess.Close() 15 17 16 - if err := base.DropTableColumns(sess, "badge", "slug"); err != nil { 17 - return err 18 - } 19 - if err := base.DropTableColumns(sess, "oauth2_application", "skip_secondary_authorization"); err != nil { 20 - return err 21 - } 22 - if err := base.DropTableColumns(sess, "repository", "default_wiki_branch"); err != nil { 23 - return err 24 - } 25 - // the migration v297.go that adds everyone_access_mode exists in Gitea >= v1.22 and the column must be dropped 26 - // but it does not exist in Forgejo and a failure to drop the column can be ignored 27 - base.DropTableColumns(sess, "repo_unit", "everyone_access_mode") 28 - 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 { 29 - return err 18 + for _, drop := range []struct { 19 + table string 20 + field string 21 + }{ 22 + {"badge", "slug"}, 23 + {"oauth2_application", "skip_secondary_authorization"}, 24 + {"repository", "default_wiki_branch"}, 25 + {"repo_unit", "everyone_access_mode"}, 26 + {"protected_branch", "can_force_push"}, 27 + {"protected_branch", "enable_force_push_allowlist"}, 28 + {"protected_branch", "force_push_allowlist_user_i_ds"}, 29 + {"protected_branch", "force_push_allowlist_team_i_ds"}, 30 + {"protected_branch", "force_push_allowlist_deploy_keys"}, 31 + } { 32 + if _, err := sess.Exec(fmt.Sprintf("SELECT `%s` FROM `%s` WHERE 0 = 1", drop.field, drop.table)); err != nil { 33 + continue 34 + } 35 + if err := base.DropTableColumns(sess, drop.table, drop.field); err != nil { 36 + return err 37 + } 30 38 } 31 39 32 40 return sess.Commit()