mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
6d0d75fbe3
Especially for godoc
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"github.com/hasura/graphql-engine/cli"
|
|
_ "github.com/hasura/graphql-engine/cli/migrate/database/hasuradb"
|
|
_ "github.com/hasura/graphql-engine/cli/migrate/source/file"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func NewMigrateCmd(ec *cli.ExecutionContext) *cobra.Command {
|
|
v := viper.New()
|
|
migrateCmd := &cobra.Command{
|
|
Use: "migrate",
|
|
Short: "Manage migrations on the database",
|
|
SilenceUsage: true,
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
ec.Viper = v
|
|
return ec.Validate()
|
|
},
|
|
}
|
|
migrateCmd.AddCommand(
|
|
newMigrateApplyCmd(ec),
|
|
newMigrateStatusCmd(ec),
|
|
newMigrateCreateCmd(ec),
|
|
)
|
|
f := migrateCmd.PersistentFlags()
|
|
f.String("endpoint", "", "http(s) endpoint for Hasura GraphQL Engine")
|
|
f.String("access-key", "", "access key for Hasura GraphQL Engine")
|
|
|
|
// need to create a new viper because https://github.com/spf13/viper/issues/233
|
|
v.BindPFlag("endpoint", f.Lookup("endpoint"))
|
|
v.BindPFlag("access_key", f.Lookup("access-key"))
|
|
return migrateCmd
|
|
}
|