12345678910111213141516171819202122232425262728293031323334353637383940 |
- package main
- import (
- "code.osinet.fr/fgm/kurz/infrastructure"
- "os"
- _ "code.osinet.fr/fgm/kurz/migrations"
- "github.com/pressly/goose"
- "github.com/spf13/cobra"
- )
- var cmdMigrateUp = &cobra.Command{
- Args: cobra.NoArgs,
- Long: "Migrate the Kurz schema to the most recent version available. Kurz version of 'goose up'.",
- Run: migrateUpHandler,
- Short: "Migrate to latest version",
- Use: "up",
- }
- func init() {
- cmdMigrate.AddCommand(cmdMigrateUp)
- }
- // migrateUpHandler implements the "kurzd migrate up" command.
- func migrateUpHandler(_ *cobra.Command, args []string) {
- dbDriver, dbDsn := infrastructure.ParseDbCred()
- db, err := infrastructure.DbDial(dbDriver, dbDsn)
- if err != nil {
- panic(err)
- }
- defer db.Close()
- cwd, err := os.Getwd()
- if err != nil {
- panic(err)
- }
- goose.SetDialect(dbDriver)
- goose.Up(db, cwd)
- }
|