init
This commit is contained in:
commit
2586161abd
49 changed files with 4171 additions and 0 deletions
31
cmd/migrate/cmd.go
Normal file
31
cmd/migrate/cmd.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package migrate
|
||||
|
||||
import (
|
||||
"emperror.dev/errors"
|
||||
"git.sleepycat.moe/sam/mercury/config"
|
||||
"git.sleepycat.moe/sam/mercury/internal/database/sql"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var Command = &cli.Command{
|
||||
Name: "migrate",
|
||||
Usage: "Run migrations on the database",
|
||||
Action: run,
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
log.Debug().Msg("Running migrations")
|
||||
|
||||
log.Debug().Msg("Reading configuration")
|
||||
cfg, err := config.Parse("config.toml")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading configuration")
|
||||
}
|
||||
|
||||
err = sql.Migrate(cfg.Core.Postgres)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "performing migrations")
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue