mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 15:42:27 -05:00
Update gorp dialect depending on DB type used
This commit is contained in:
parent
c1dc6a21e8
commit
9abafa50b2
16
db.go
16
db.go
@ -17,7 +17,21 @@ func initDB(cfg *Config) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}
|
||||
var dialect gorp.Dialect
|
||||
if cfg.MoneyGo.DBType == SQLite {
|
||||
dialect = gorp.SqliteDialect{}
|
||||
} else if cfg.MoneyGo.DBType == MySQL {
|
||||
dialect = gorp.MySQLDialect{
|
||||
Engine: "InnoDB",
|
||||
Encoding: "UTF8",
|
||||
}
|
||||
} else if cfg.MoneyGo.DBType == Postgres {
|
||||
dialect = gorp.PostgresDialect{}
|
||||
} else {
|
||||
log.Fatalf("Don't know gorp dialect to go with '%s' DB type", cfg.MoneyGo.DBType.String())
|
||||
}
|
||||
|
||||
dbmap := &gorp.DbMap{Db: db, Dialect: dialect}
|
||||
dbmap.AddTableWithName(User{}, "users").SetKeys(true, "UserId")
|
||||
dbmap.AddTableWithName(Session{}, "sessions").SetKeys(true, "SessionId")
|
||||
dbmap.AddTableWithName(Account{}, "accounts").SetKeys(true, "AccountId")
|
||||
|
Loading…
Reference in New Issue
Block a user