mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
Allow database URL to be specified via command line
This commit is contained in:
parent
99a4f266e6
commit
ece5d3cf0e
4 changed files with 36 additions and 9 deletions
13
main.go
13
main.go
|
|
@ -11,6 +11,12 @@ import (
|
|||
func main() {
|
||||
loadDotEnv()
|
||||
|
||||
app := NewApp()
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
// NewApp creates a new command line app
|
||||
func NewApp() *cli.App {
|
||||
app := cli.NewApp()
|
||||
app.Name = "dbmate"
|
||||
app.Usage = "A lightweight, framework-independent database migration tool."
|
||||
|
|
@ -21,6 +27,11 @@ func main() {
|
|||
Value: "./db/migrations",
|
||||
Usage: "specify the directory containing migration files",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "env, e",
|
||||
Value: "DATABASE_URL",
|
||||
Usage: "specify an environment variable containing the database URL",
|
||||
},
|
||||
}
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
|
|
@ -54,7 +65,7 @@ func main() {
|
|||
},
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
return app
|
||||
}
|
||||
|
||||
type command func(*cli.Context) error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue