Skip to content

Commit

Permalink
Update xorm and dependencies vendor for feature to dump to other data…
Browse files Browse the repository at this point in the history
…base (#565)

* update xorm and dependencies vendor for feature to dump to other database

* fix golint
  • Loading branch information
lunny authored Jan 3, 2017
1 parent 70900bd commit 980dd0b
Show file tree
Hide file tree
Showing 54 changed files with 4,156 additions and 3,640 deletions.
14 changes: 12 additions & 2 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
Value: os.TempDir(),
Usage: "Temporary dir path",
},
cli.StringFlag{
Name: "database, d",
Usage: "Specify the database SQL syntax",
},
},
}

Expand Down Expand Up @@ -71,8 +75,14 @@ func runDump(ctx *cli.Context) error {
log.Fatalf("Fail to dump local repositories: %v", err)
}

log.Printf("Dumping database...")
if err := models.DumpDatabase(dbDump); err != nil {
targetDBType := ctx.String("database")
if len(targetDBType) > 0 && targetDBType != models.DbCfg.Type {
log.Printf("Dumping database %s => %s...", models.DbCfg.Type, targetDBType)
} else {
log.Printf("Dumping database...")
}

if err := models.DumpDatabase(dbDump, targetDBType); err != nil {
log.Fatalf("Fail to dump database: %v", err)
}

Expand Down
13 changes: 10 additions & 3 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,14 @@ func Ping() error {
return x.Ping()
}

// DumpDatabase dumps all data from database to file system.
func DumpDatabase(filePath string) error {
return x.DumpAllToFile(filePath)
// DumpDatabase dumps all data from database according the special database SQL syntax to file system.
func DumpDatabase(filePath string, dbType string) error {
var tbs []*core.Table
for _, t := range tables {
tbs = append(tbs, x.TableInfo(t).Table)
}
if len(dbType) > 0 {
return x.DumpTablesToFile(tbs, filePath, core.DbType(dbType))
}
return x.DumpTablesToFile(tbs, filePath)
}
4 changes: 3 additions & 1 deletion vendor/github.com/go-xorm/builder/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions vendor/github.com/go-xorm/builder/builder.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/go-xorm/builder/builder_delete.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/go-xorm/builder/builder_insert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/go-xorm/builder/builder_select.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/go-xorm/builder/builder_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/github.com/go-xorm/builder/circle.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions vendor/github.com/go-xorm/builder/cond.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/go-xorm/builder/cond_and.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion vendor/github.com/go-xorm/builder/cond_between.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 980dd0b

Please sign in to comment.