diff options
author | zeripath <art27@cantab.net> | 2020-09-06 22:52:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-06 22:52:01 +0100 |
commit | 1b9d5074a7ebb1b470f468cc9195d54915291ee3 (patch) | |
tree | 1045623ccc744aedb934017f6bf8ae345131db17 /integrations/migration-test | |
parent | ad2bf376dfd934394cad46c3ff3e022ca232958f (diff) | |
download | gitea-1b9d5074a7ebb1b470f468cc9195d54915291ee3.tar.gz gitea-1b9d5074a7ebb1b470f468cc9195d54915291ee3.zip |
Add command to recreate tables (#12407)
Provides new command: `gitea doctor recreate-table` which will recreate
db tables and copy the old data in to the new table.
This function can be used to remove the old warning of struct defaults being
out of date.
Fix #8868
Fix #3265
Fix #8894
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'integrations/migration-test')
-rw-r--r-- | integrations/migration-test/migration_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go index 976a59a579..940e4738ad 100644 --- a/integrations/migration-test/migration_test.go +++ b/integrations/migration-test/migration_test.go @@ -258,6 +258,30 @@ func doMigrationTest(t *testing.T, version string) { err = models.NewEngine(context.Background(), wrappedMigrate) assert.NoError(t, err) currentEngine.Close() + + err = models.SetEngine() + assert.NoError(t, err) + + beans, _ := models.NamesToBean() + + err = models.NewEngine(context.Background(), func(x *xorm.Engine) error { + currentEngine = x + return migrations.RecreateTables(beans...)(x) + }) + assert.NoError(t, err) + currentEngine.Close() + + // We do this a second time to ensure that there is not a problem with retained indices + err = models.SetEngine() + assert.NoError(t, err) + + err = models.NewEngine(context.Background(), func(x *xorm.Engine) error { + currentEngine = x + return migrations.RecreateTables(beans...)(x) + }) + assert.NoError(t, err) + + currentEngine.Close() } func TestMigrations(t *testing.T) { |