fix: Gitea last drop

Some database fields were added in the database to facilitate
migration from Gitea and do not serve any purpose. Drop them since
v1.22 is the last version of the database to allow a transparent
migration to Forgejo.
This commit is contained in:
Earl Warren 2024-12-23 08:24:40 +01:00
parent 1fffd116e5
commit 274bc480b4
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 36 additions and 0 deletions

View file

@ -362,6 +362,9 @@ func prepareMigrationTasks() []*migration {
newMigration(300, "Add force-push branch protection support", v1_23.AddForcePushBranchProtection),
newMigration(301, "Add skip_secondary_authorization option to oauth2 application table", v1_23.AddSkipSecondaryAuthColumnToOAuth2ApplicationTable),
newMigration(302, "Add index to action_task stopped log_expired", v1_23.AddIndexToActionTaskStoppedLogExpired),
// Migration to Forgejo v10
newMigration(303, "Gitea last drop", v1_23.GiteaLastDrop),
}
return preparedMigrations
}

View file

@ -0,0 +1,33 @@
// Copyright 2024 The Forgejo Authors.
// SPDX-License-Identifier: MIT
package v1_23 //nolint
import (
"code.gitea.io/gitea/models/migrations/base"
"xorm.io/xorm"
)
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
}
return sess.Commit()
}