diff options
author | 6543 <6543@obermui.de> | 2020-09-08 00:27:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-07 23:27:17 +0100 |
commit | cfd8e8a489f7f5e80584bd7190a7cb2120e2fa8b (patch) | |
tree | f40b2e1714235edfe74dfb228ec4d08cefff03ae /models | |
parent | 226aef7e0f9addfd254558eb4fd633946551664b (diff) | |
download | gitea-cfd8e8a489f7f5e80584bd7190a7cb2120e2fa8b.tar.gz gitea-cfd8e8a489f7f5e80584bd7190a7cb2120e2fa8b.zip |
gitea dump: include version & Check InstallLock (#12760)
* gitea dump: include version
* Check InstallLock (close #12759)
* fix test
* fix lint
Diffstat (limited to 'models')
-rw-r--r-- | models/models.go | 11 | ||||
-rw-r--r-- | models/models_test.go | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go index 27a0c660be..32df9bdfd8 100644 --- a/models/models.go +++ b/models/models.go @@ -302,6 +302,17 @@ func DumpDatabase(filePath string, dbType string) error { } tbs = append(tbs, t) } + + type Version struct { + ID int64 `xorm:"pk autoincr"` + Version int64 + } + t, err := x.TableInfo(Version{}) + if err != nil { + return err + } + tbs = append(tbs, t) + if len(dbType) > 0 { return x.DumpTablesToFile(tbs, filePath, schemas.DBType(dbType)) } diff --git a/models/models_test.go b/models/models_test.go index 37e9a352f8..2441ad7fb0 100644 --- a/models/models_test.go +++ b/models/models_test.go @@ -21,6 +21,12 @@ func TestDumpDatabase(t *testing.T) { dir, err := ioutil.TempDir(os.TempDir(), "dump") assert.NoError(t, err) + type Version struct { + ID int64 `xorm:"pk autoincr"` + Version int64 + } + assert.NoError(t, x.Sync2(Version{})) + for _, dbName := range setting.SupportedDatabases { dbType := setting.GetDBTypeByName(dbName) assert.NoError(t, DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType)) |