feat(migrate): add lifecycle commands and standalone authoring
This commit is contained in:
1 parent
3cd3f49c11
commit
2727ac83db
12 files changed
+1553
-31
No files matched your search
@@ -0,0 +1,40 @@
|
||||
// Command corestack-goose authors provider-local SQL and Go migrations offline.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
urfavecli "github.com/urfave/cli/v3"
|
||||
"go.auvem.com/corestack/cmd/corestack-goose/internal/authoring"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command().Run(context.Background(), os.Args); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func command() *urfavecli.Command {
|
||||
root := &urfavecli.Command{Name: "corestack-goose", Usage: "Author migrations before deployment"}
|
||||
for _, name := range []string{"create", "fix"} {
|
||||
root.Commands = append(root.Commands, &urfavecli.Command{Name: name,
|
||||
Flags: []urfavecli.Flag{&urfavecli.StringFlag{Name: "dir", Required: true}},
|
||||
Action: func(_ context.Context, cmd *urfavecli.Command) error {
|
||||
if name == "create" {
|
||||
if cmd.NArg() != 2 {
|
||||
return fmt.Errorf("usage: create --dir <dir> <name> sql|go")
|
||||
}
|
||||
return authoring.Create(cmd.String("dir"), cmd.Args().Get(0), cmd.Args().Get(1))
|
||||
}
|
||||
if cmd.NArg() != 0 {
|
||||
return fmt.Errorf("usage: fix --dir <dir>")
|
||||
}
|
||||
return authoring.Fix(cmd.String("dir"))
|
||||
},
|
||||
})
|
||||
}
|
||||
return root
|
||||
}
|
||||
Reference in new issue
Block a user