Skip to content

Commit 7a25441

Browse files
authored
gitea dump: include version & Check InstallLock (#12760) (#12762)
* gitea dump: include version * Check InstallLock
1 parent dc71d00 commit 7a25441

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

cmd/dump.go

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func fatal(format string, args ...interface{}) {
6666

6767
func runDump(ctx *cli.Context) error {
6868
setting.NewContext()
69+
if !setting.InstallLock {
70+
log.Error("Is '%s' really the right config path?\n", setting.CustomConf)
71+
return fmt.Errorf("gitea is not initialized")
72+
}
6973
setting.NewServices() // cannot access session settings otherwise
7074

7175
err := models.SetEngine()

models/models.go

+11
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,17 @@ func DumpDatabase(filePath string, dbType string) error {
264264
}
265265
tbs = append(tbs, t)
266266
}
267+
268+
type Version struct {
269+
ID int64 `xorm:"pk autoincr"`
270+
Version int64
271+
}
272+
t, err := x.TableInfo(Version{})
273+
if err != nil {
274+
return err
275+
}
276+
tbs = append(tbs, t)
277+
267278
if len(dbType) > 0 {
268279
return x.DumpTablesToFile(tbs, filePath, schemas.DBType(dbType))
269280
}

models/models_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ func TestDumpDatabase(t *testing.T) {
2121
dir, err := ioutil.TempDir(os.TempDir(), "dump")
2222
assert.NoError(t, err)
2323

24+
type Version struct {
25+
ID int64 `xorm:"pk autoincr"`
26+
Version int64
27+
}
28+
assert.NoError(t, x.Sync2(Version{}))
29+
2430
for _, dbName := range setting.SupportedDatabases {
2531
dbType := setting.GetDBTypeByName(dbName)
2632
assert.NoError(t, DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))

0 commit comments

Comments
 (0)