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 cmdMigrateRedo = &cobra.Command{ Args: cobra.NoArgs, Long: "Migrate the Kurz schema to the most recent version available. Kurz version of 'goose redo'.", Run: migrateRedoHandler, Short: "Migrate to latest version", Use: "redo", } func init() { cmdMigrate.AddCommand(cmdMigrateRedo) } // migrateRedoHandler implements the "kurzd migrate redo" command. func migrateRedoHandler(_ *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.Redo(db, cwd) }