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 cmdMigrateVersion = &cobra.Command{ Args: cobra.NoArgs, Long: "Kurz version of goose version", Run: migrateVersionHandler, Short: "Migration version", Use: "version", } func init() { cmdMigrate.AddCommand(cmdMigrateVersion) } // migrateVersionHandler implements the "kurzd migrate version" command. func migrateVersionHandler(_ *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.Version(db, cwd) }