forked from forgejo/forgejo
[DB] Forgejo database migrations
- Implements https://codeberg.org/forgejo/discussions/issues/32#issuecomment-918737 - Allows to add Forgejo-specific migrations that don't interfere with Gitea's migration logic. Please do note that we cannot liberally add migrations for Gitea tables, as they might do their own migrations in a future version on that table, and that could undo our migrations. Luckily, we don't have a scenario where that's needed and thus not taken into account. Co-authored-by: Gusted <postmaster@gusted.xyz> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/795 (cherry picked from commit8ee32978c0
) (cherry picked from commitc240b34f59
) (cherry picked from commit03936c6492
) (cherry picked from commita20ed852f8
) (cherry picked from commit1dfa82676f
) (cherry picked from commitc39ae0bf8a
) (cherry picked from commitcfaff08996
) (cherry picked from commit94a458835a
) (cherry picked from commit61a3cf77df
) (cherry picked from commitabb350fde8
) (cherry picked from commit5194829d6b
) (cherry picked from commit89239a60f2
) (cherry picked from commit683cfd86ef
) (cherry picked from commitf4546cfed9
) (cherry picked from commit86614d5826
) (cherry picked from commite4b9c32187
) (cherry picked from commit8c253719af
) (cherry picked from commit857365d6c1
) (cherry picked from commita488b3952f
) (cherry picked from commit98313c4910
) (cherry picked from commit430d95e824
) (cherry picked from commit08bf9d918f
) (cherry picked from commitf8a170e2d0
) (cherry picked from commitd20e325378
) (cherry picked from commit6c0aa7dd4f
) (cherry picked from commit46c08c26c7
) (cherry picked from commit9ee22153c4
) [DB] Ensure forgejo migration up to date (squash) - Hook Forgejo's `EnsureUpToDate` to Gitea's `EnsureUpToDate`, such that the Forgejo migrations are also being checked to be up to date. - I'm not sure how I missed this and if this has caused any problems, but due to the lack of any open issue about it it seems to not be a big problem. (cherry picked from commit6c65b6dcf6
) (cherry picked from commit6d45c37d84
) [DB] Add test for TestEnsureUpToDate (squash) - Add a test for the behavior of `EnsureUpToDate`, to ensure it will error when needed and succeed when the forgejo version is up to date. - Add forgejo_migrations package to GO_TEST_PACKAGES, to avoid running it with `test-unit` and instead test it with `test-*-migration`. (cherry picked from commitb172a50691
) (cherry picked from commitd8af308820
)
This commit is contained in:
parent
25f840379f
commit
e69e64a32c
5 changed files with 202 additions and 7 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/models/forgejo_migrations"
|
||||
"code.gitea.io/gitea/models/migrations/v1_10"
|
||||
"code.gitea.io/gitea/models/migrations/v1_11"
|
||||
"code.gitea.io/gitea/models/migrations/v1_12"
|
||||
|
@ -595,7 +596,7 @@ func EnsureUpToDate(x *xorm.Engine) error {
|
|||
return fmt.Errorf(`Current database version %d is not equal to the expected version %d. Please run "gitea [--config /path/to/app.ini] migrate" to update the database version`, currentDB, expected)
|
||||
}
|
||||
|
||||
return nil
|
||||
return forgejo_migrations.EnsureUpToDate(x)
|
||||
}
|
||||
|
||||
// Migrate database to current version
|
||||
|
@ -659,5 +660,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
|
|||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
// Execute Forgejo specific migrations.
|
||||
return forgejo_migrations.Migrate(x)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue