feat(init): First commit

This commit is contained in:
Thomas Maurice 2024-02-11 19:59:34 +01:00
commit f92368748a
Signed by: thomas
GPG key ID: 1D577F50583032A6
22 changed files with 1298 additions and 0 deletions

25
pkg/cmd/initdb.go Normal file
View 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")
},
}