-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate.go
44 lines (38 loc) · 941 Bytes
/
migrate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cmd
import (
"github.com/spf13/cobra"
)
func (h *Handler) NewMigrate() *cobra.Command {
cmd := &cobra.Command{
Use: "migrate",
Short: "Manage migrations from the core and your own project",
}
RegisterFlags(cmd.PersistentFlags())
return cmd
}
func (h *Handler) NewMigratUp() *cobra.Command {
cmd := &cobra.Command{
Use: "up",
Short: "Migrating up files from migration folder",
Run: func(cmd *cobra.Command, args []string) {
r := h.GenerateRegistry(cmd.Context())
if err := r.Migration().Up(); err != nil {
r.Logger().Errorln(err)
}
},
}
return cmd
}
func (h *Handler) NewMigratDown() *cobra.Command {
cmd := &cobra.Command{
Use: "down",
Short: "Migrating down files from migration folder",
Run: func(cmd *cobra.Command, args []string) {
r := h.GenerateRegistry(cmd.Context())
if err := r.Migration().Down(); err != nil {
r.Logger().Errorln(err)
}
},
}
return cmd
}