mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 08:00:04 +01:00
parent
ed9e57a4ad
commit
079523c25f
2 changed files with 13 additions and 4 deletions
|
|
@ -284,12 +284,12 @@ Waiting for database....
|
||||||
Creating: myapp_development
|
Creating: myapp_development
|
||||||
```
|
```
|
||||||
|
|
||||||
If the database is still not available after 60 seconds, the command will return an error:
|
You can customize the timeout using `--wait-timeout` (default 60s). If the database is still not available, the command will return an error:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ dbmate wait
|
$ dbmate --wait-timeout=5s wait
|
||||||
Waiting for database............................................................
|
Waiting for database.....
|
||||||
Error: unable to connect to database: pq: role "foobar" does not exist
|
Error: unable to connect to database: dial tcp 127.0.0.1:5432: connect: connection refused
|
||||||
```
|
```
|
||||||
|
|
||||||
Please note that the `wait` command does not verify whether your specified database exists, only that the server is available and ready (so it will return success if the database server is available, but your database has not yet been created).
|
Please note that the `wait` command does not verify whether your specified database exists, only that the server is available and ready (so it will return success if the database server is available, but your database has not yet been created).
|
||||||
|
|
|
||||||
9
main.go
9
main.go
|
|
@ -55,6 +55,11 @@ func NewApp() *cli.App {
|
||||||
Name: "wait",
|
Name: "wait",
|
||||||
Usage: "wait for the db to become available before executing the subsequent command",
|
Usage: "wait for the db to become available before executing the subsequent command",
|
||||||
},
|
},
|
||||||
|
cli.DurationFlag{
|
||||||
|
Name: "wait-timeout",
|
||||||
|
Usage: "timeout for --wait flag",
|
||||||
|
Value: dbmate.DefaultWaitTimeout,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
|
|
@ -177,6 +182,10 @@ func action(f func(*dbmate.DB, *cli.Context) error) cli.ActionFunc {
|
||||||
db.MigrationsDir = c.GlobalString("migrations-dir")
|
db.MigrationsDir = c.GlobalString("migrations-dir")
|
||||||
db.SchemaFile = c.GlobalString("schema-file")
|
db.SchemaFile = c.GlobalString("schema-file")
|
||||||
db.WaitBefore = c.GlobalBool("wait")
|
db.WaitBefore = c.GlobalBool("wait")
|
||||||
|
overrideTimeout := c.GlobalDuration("wait-timeout")
|
||||||
|
if overrideTimeout != 0 {
|
||||||
|
db.WaitTimeout = overrideTimeout
|
||||||
|
}
|
||||||
|
|
||||||
return f(db, c)
|
return f(db, c)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue