mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-05 11:10:47 -06:00
38 lines
737 B
Go
38 lines
737 B
Go
package command
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/shroff/phylum/server/internal/app"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func setupSchemaCommand() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "schema",
|
|
Short: "Database Schema Management",
|
|
}
|
|
cmd.AddCommand([]*cobra.Command{
|
|
setupSchemaMigrateCommand(),
|
|
}...)
|
|
return cmd
|
|
}
|
|
|
|
func setupSchemaMigrateCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "migrate",
|
|
Short: "Migrate Database Schema",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
v, err := strconv.Atoi(args[0])
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
if err = app.Default.MigrateDb(v); err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
},
|
|
}
|
|
}
|