Rewrite migrations to not depend on future code changes - #2604
Conversation
* change repoUnit model in migration * fix v16 migration repo_unit table * fix lint error * move type definition inside function Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #2604 +/- ##
=======================================
Coverage 27.13% 27.13%
=======================================
Files 86 86
Lines 17062 17062
=======================================
Hits 4629 4629
Misses 11755 11755
Partials 678 678Continue to review full report at Codecov.
|
|
Currently there is an issue in v39 (introduced in this PR) which needs to be fixed before merging |
|
@daviian what issue? |
|
@lafriks https://github.com/daviian/gitea/blob/c9430b29a5220e2297aa9b93b70a25062f831509/models/migrations/v39.go#L73 |
* change repoUnit model in migration * fix v16 migration repo_unit table * fix lint error * move type definition inside function Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
c840545 to
54f684d
Compare
…o daviian-backport/migration-fix
| users := make([]*models.User, 0, batchSize) | ||
| if err := x.Limit(start, batchSize).Find(users); err != nil { | ||
| users := make([]*User, 0, batchSize) | ||
| if err := x.Limit(batchSize, start).Find(&users); err != nil { |
There was a problem hiding this comment.
Good catch. Nearly impossible to see
|
Any chance to see an automated test for migration from a dump of a Gogs0.99 database ? |
|
@strk not in the scope of this PR but otherwise I agree we would need that but I currently have no idea how to achieve that |
|
Trusted/untested LGTM - please make sure to manually test it !
|
|
Just tried this on a database with I kind of followed https://docs.gitea.io/en-us/install-from-source/ and https://docs.gitea.io/en-us/upgrade-from-gogs/ and @lafriks told me to change the |
|
@mrexodia Glad to here that 😃 Setting the version to 14 is necessary as otherwise required migrations (in your example 14 to 17) are not applied to the database. |
|
Make LG-TM work again |
a5e38d2 to
d53ab74
Compare
|
@daviian sure, go ahead |
* v38 migration used an outdated version of RepoUnit model (go-gitea#2602) * change repoUnit model in migration * fix v16 migration repo_unit table * fix lint error * move type definition inside function * Fix migration from Gogs * Refactor code * add error check * Additiomal fixes for migrations * Add back nil check
* Rewrite migrations to not depend on future code changes (#2604) * v38 migration used an outdated version of RepoUnit model (#2602) * change repoUnit model in migration * fix v16 migration repo_unit table * fix lint error * move type definition inside function * Fix migration from Gogs * Refactor code * add error check * Additiomal fixes for migrations * Add back nil check * replace deprecated .Id with .ID Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * change string map to interface map Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Backport of #2602