Add --wait flag (#112)

 When using dbmate as a container, since the base image is distroless, we can't do `dbmate up && dbmate wait`, which makes config a bit more cumbersome (e.g. in kubernetes an extra initContainer).

Closes #111
Closes #112
This commit is contained in:
Reuben Thomas-Davis 2019-12-31 20:47:27 +00:00 committed by Adrian Macneil
parent 98066fadaa
commit 1e45bd774c
4 changed files with 107 additions and 0 deletions

View file

@ -50,6 +50,10 @@ func NewApp() *cli.App {
Name: "no-dump-schema",
Usage: "don't update the schema file on migrate/rollback",
},
cli.BoolFlag{
Name: "wait",
Usage: "wait for the db to become available before executing the subsequent command",
},
}
app.Commands = []cli.Command{
@ -139,6 +143,7 @@ func action(f func(*dbmate.DB, *cli.Context) error) cli.ActionFunc {
db.AutoDumpSchema = !c.GlobalBool("no-dump-schema")
db.MigrationsDir = c.GlobalString("migrations-dir")
db.SchemaFile = c.GlobalString("schema-file")
db.WaitBefore = c.GlobalBool("wait")
return f(db, c)
}