mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
38 lines
857 B
Go
38 lines
857 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package db
|
|
|
|
import (
|
|
"github.com/hanzoai/git/modules/setting"
|
|
|
|
"github.com/hanzoai/xorm/schemas"
|
|
)
|
|
|
|
// DumpDatabase dumps all data from database according the special database SQL syntax to file system.
|
|
func DumpDatabase(filePath string, dbType setting.DatabaseType) error {
|
|
var tbs []*schemas.Table
|
|
for _, t := range registeredModels {
|
|
t, err := xormEngine.TableInfo(t)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
tbs = append(tbs, t)
|
|
}
|
|
|
|
type Version struct {
|
|
ID int64 `xorm:"pk autoincr"`
|
|
Version int64
|
|
}
|
|
t, err := xormEngine.TableInfo(&Version{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
tbs = append(tbs, t)
|
|
|
|
if dbType != "" {
|
|
return xormEngine.DumpTablesToFile(tbs, filePath, schemas.DBType(dbType))
|
|
}
|
|
return xormEngine.DumpTablesToFile(tbs, filePath)
|
|
}
|