25 lines
570 B
Go
25 lines
570 B
Go
package cmd
|
|
|
|
import (
|
|
"git.maurice.fr/thomas/mailout/pkg/database"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var InitDBCmd = &cobra.Command{
|
|
Use: "initdb",
|
|
Short: "initialises the database",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
db, err := database.NewDB(cfg)
|
|
if err != nil {
|
|
logrus.WithError(err).Fatal("could not connect to the database")
|
|
}
|
|
|
|
err = database.InitMigrate(db)
|
|
if err != nil {
|
|
logrus.WithError(err).Fatal("could not initialise the database")
|
|
}
|
|
|
|
logrus.Info("successfully initialised the database")
|
|
},
|
|
}
|