feat(init): First commit
This commit is contained in:
commit
f92368748a
22 changed files with 1298 additions and 0 deletions
25
pkg/cmd/initdb.go
Normal file
25
pkg/cmd/initdb.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
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")
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue