34 lines
596 B
Go
34 lines
596 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"trankilou.fr/lassistanoque/backend/internal/adapter/database"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(
|
|
newLigrateCmd(),
|
|
)
|
|
}
|
|
|
|
// newVersionCmd creates the version command for displaying version information.
|
|
func newLigrateCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "migrate",
|
|
Short: "migrate database",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
db, err := database.GetDatabase()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer db.Close()
|
|
|
|
err = db.Migrate()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
},
|
|
}
|
|
return cmd
|
|
}
|