-
Notifications
You must be signed in to change notification settings - Fork 0
/
schemaflow.go
51 lines (39 loc) · 1.16 KB
/
schemaflow.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
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"log"
"schemaflow/core"
)
func perr(err error) {
core.Perr(err)
}
func main() {
/*
TODO:
- Bring back the versioned migrations system
- Bring back the "makemigrations", "migrate", and "clean" commands"
- Move the automatic migration generation files to their own module
- Move the versioned migrations code to its own folder
- By default, when generating the migration file, the migrations file should show that there is a change that was made to a specific statement, but not generate any migrations automatically.
- If the "--auto-gen" flag is set, then for each changed statement migrations will attempted to be created automatically, but will still require validation.
*/
ctx := core.ParseArgs()
ctx.Db = core.CreateDbConnections(ctx.DbContext)
defer ctx.Db.Close()
db_tx, te := ctx.Db.Begin()
ctx.DbTx = db_tx
perr(te)
core.Initialize(ctx)
switch ctx.Action {
case core.MIGRATE: {
core.Migrate(ctx)
}
case core.MAKEMIGRATIONS: {
core.MakeMigrations(ctx)
}
case core.CLEAN: {
core.Clean(ctx)
}
}
perr(ctx.DbTx.Commit())
log.Println("Done.")
}