-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialect.go
39 lines (34 loc) · 949 Bytes
/
dialect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package migrations
func GetCreateTableByDialect(dialect string) string {
switch dialect {
case "postgress":
return "CREATE TABLE IF NOT EXISTS main.migrations (migration INTEGER NOT NULL);"
case "sqlite3":
return "CREATE TABLE IF NOT EXISTS migrations (migration INTEGER NOT NULL);"
default:
panic("Could not figure out how to set up the migrations table")
}
return ""
}
func InsertNewEntry(dialect string) string {
switch dialect {
case "postgress":
return "INSERT INTO main.migrations VALUES ($1);"
case "sqlite3":
return "INSERT INTO migrations VALUES ($1);"
default:
panic("Could not figure out how to mark this migration as ran")
}
return ""
}
func QueryForRanMigrations(dialect string) string {
switch dialect {
case "postgress":
return "SELECT migration FROM main.migrations"
case "sqlite3":
return "SELECT migration FROM migrations"
default:
panic("Could not query for ran migrations")
}
return ""
}