More progress on db schema setup and migrations, tricky stuff

This commit is contained in:
Torkel Ödegaard
2015-01-18 13:08:59 +01:00
parent 38f237efcb
commit 68a77c4051
9 changed files with 146 additions and 40 deletions
@@ -3,9 +3,27 @@ package migrations
type migration struct {
desc string
sqlite string
mysql string
verifyTable string
}
type columnType string
const (
DB_TYPE_STRING columnType = "String"
)
func (m *migration) getSql(dbType string) string {
switch dbType {
case "mysql":
return m.mysql
case "sqlite3":
return m.sqlite
}
panic("db type not supported")
}
type migrationBuilder struct {
migration *migration
}
@@ -15,6 +33,11 @@ func (b *migrationBuilder) sqlite(sql string) *migrationBuilder {
return b
}
func (b *migrationBuilder) mysql(sql string) *migrationBuilder {
b.migration.mysql = sql
return b
}
func (b *migrationBuilder) verifyTable(name string) *migrationBuilder {
b.migration.verifyTable = name
return b