* Revert "[MM-41576] Revamp database schema version (#19586)" This reverts commit645fee3fe3. * Revert "MM-42049 - license endpoint not working (#19686)" This reverts commit4fe89e5847.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
eff39010d8
Коммит
a2a78577e9
@@ -5,7 +5,6 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -52,21 +51,13 @@ var MigrateCmd = &cobra.Command{
|
||||
RunE: migrateCmdF,
|
||||
}
|
||||
|
||||
var DBVersionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Returns the recent applied version number",
|
||||
RunE: dbVersionCmdF,
|
||||
}
|
||||
|
||||
func init() {
|
||||
ResetCmd.Flags().Bool("confirm", false, "Confirm you really want to delete everything and a DB backup has been performed.")
|
||||
DBVersionCmd.Flags().Bool("all", false, "Returns all applied migrations")
|
||||
|
||||
DbCmd.AddCommand(
|
||||
InitDbCmd,
|
||||
ResetCmd,
|
||||
MigrateCmd,
|
||||
DBVersionCmd,
|
||||
)
|
||||
|
||||
RootCmd.AddCommand(
|
||||
@@ -146,35 +137,3 @@ func migrateCmdF(command *cobra.Command, args []string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dbVersionCmdF(command *cobra.Command, args []string) error {
|
||||
cfgDSN := getConfigDSN(command, config.GetEnvironment())
|
||||
cfgStore, err := config.NewStoreFromDSN(cfgDSN, true, nil, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to load configuration")
|
||||
}
|
||||
config := cfgStore.Get()
|
||||
|
||||
store := sqlstore.New(config.SqlSettings, nil)
|
||||
defer store.Close()
|
||||
|
||||
allFlag, _ := command.Flags().GetBool("all")
|
||||
if allFlag {
|
||||
applied, err2 := store.GetAppliedMigrations()
|
||||
if err2 != nil {
|
||||
return errors.Wrap(err2, "failed to get applied migrations")
|
||||
}
|
||||
for _, migration := range applied {
|
||||
CommandPrettyPrintln(fmt.Sprintf("Varsion: %d, Name: %s", migration.Version, migration.Name))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
v, err := store.GetDBSchemaVersion()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get schema version")
|
||||
}
|
||||
CommandPrettyPrintln("Current database schema version is: " + strconv.Itoa(v))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user