Skip to content

Commit a57857c

Browse files
committed
Add general support for more database types
1 parent cceeb3e commit a57857c

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

sync/server_deploy_database.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ import (
66
)
77

88
func (database *Database) Deploy() {
9-
if database.Options.ClearDatabase {
10-
database.deployClearDatabase()
11-
}
9+
switch database.Type {
10+
case "mysql":
11+
if database.Options.ClearDatabase {
12+
database.deployMysqlClearDatabase()
13+
}
1214

13-
database.deployStructure()
14-
database.deployData()
15+
database.deployMysqlStructure()
16+
database.deployMysqlData()
17+
default:
18+
panic(fmt.Sprintf("Database type %s is not valid or supported", database.Type))
19+
}
1520
}
1621

1722
// Deploy database structure
18-
func (database *Database) deployClearDatabase() {
23+
func (database *Database) deployMysqlClearDatabase() {
1924

2025
// don't use database which we're trying to drop, instead use "mysql"
2126
schema := database.Schema
@@ -35,7 +40,7 @@ func (database *Database) deployClearDatabase() {
3540
}
3641

3742
// Deploy database structure
38-
func (database *Database) deployStructure() {
43+
func (database *Database) deployMysqlStructure() {
3944
Logger.Step("deploy database structure")
4045

4146
// Deploy structure only
@@ -47,7 +52,7 @@ func (database *Database) deployStructure() {
4752
}
4853

4954
// Deploy database data
50-
func (database *Database) deployData() {
55+
func (database *Database) deployMysqlData() {
5156
Logger.Step("deploy database data")
5257

5358
// Deploy data only

sync/server_sync_database.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ import (
88
)
99

1010
func (database *Database) Sync() {
11-
if database.Options.ClearDatabase {
12-
database.syncClearDatabase()
11+
switch database.Type {
12+
case "mysql":
13+
if database.Options.ClearDatabase {
14+
database.syncMysqlClearDatabase()
15+
}
16+
17+
database.syncMysqlStructure()
18+
database.syncMysqlData()
19+
default:
20+
panic(fmt.Sprintf("Database type %s is not valid or supported", database.Type))
1321
}
14-
15-
database.syncStructure()
16-
database.syncData()
1722
}
1823

1924
// Sync database structure
20-
func (database *Database) syncClearDatabase() {
25+
func (database *Database) syncMysqlClearDatabase() {
2126

2227
// don't use database which we're trying to drop, instead use "mysql"
2328
schema := database.Local.Schema
@@ -37,7 +42,7 @@ func (database *Database) syncClearDatabase() {
3742
}
3843

3944
// Sync database structure
40-
func (database *Database) syncStructure() {
45+
func (database *Database) syncMysqlStructure() {
4146
Logger.Step("syncing database structure")
4247

4348
tmpfile, err := ioutil.TempFile("", "dump")
@@ -56,7 +61,7 @@ func (database *Database) syncStructure() {
5661
}
5762

5863
// Sync database data
59-
func (database *Database) syncData() {
64+
func (database *Database) syncMysqlData() {
6065
Logger.Step("syncing database data")
6166

6267
tmpfile, err := ioutil.TempFile("", "dump")

0 commit comments

Comments
 (0)