Add Up command to create database and migrate

This commit is contained in:
Adrian Macneil 2015-11-27 10:34:42 -08:00
parent 1c4cf2c122
commit 164ec81370
5 changed files with 125 additions and 31 deletions

35
main.go
View file

@ -35,20 +35,6 @@ func NewApp() *cli.App {
}
app.Commands = []cli.Command{
{
Name: "migrate",
Usage: "Migrate to the latest version",
Action: func(ctx *cli.Context) {
runCommand(MigrateCommand, ctx)
},
},
{
Name: "rollback",
Usage: "Rollback the most recent migration",
Action: func(ctx *cli.Context) {
runCommand(RollbackCommand, ctx)
},
},
{
Name: "new",
Usage: "Generate a new migration file",
@ -56,6 +42,13 @@ func NewApp() *cli.App {
runCommand(NewCommand, ctx)
},
},
{
Name: "up",
Usage: "Create database (if necessary) and migrate to the latest version",
Action: func(ctx *cli.Context) {
runCommand(UpCommand, ctx)
},
},
{
Name: "create",
Usage: "Create database",
@ -70,6 +63,20 @@ func NewApp() *cli.App {
runCommand(DropCommand, ctx)
},
},
{
Name: "migrate",
Usage: "Migrate to the latest version",
Action: func(ctx *cli.Context) {
runCommand(MigrateCommand, ctx)
},
},
{
Name: "rollback",
Usage: "Rollback the most recent migration",
Action: func(ctx *cli.Context) {
runCommand(RollbackCommand, ctx)
},
},
}
return app