Skip to content

Commit

Permalink
fix(migrate): confirm before migration
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Dec 23, 2023
1 parent 21803a9 commit 52e140f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,8 @@ import (
)

func Migrate(ctx context.Context, to map[string]string) error {
meta, err := kv.From(ctx).MigrateTo()
if err != nil {
return errors.Wrap(err, "read data")
}

dest, err := kv.NewWithMap(to)
if err != nil {
return errors.Wrap(err, "create dest storage")
}

var confirm bool
if err = survey.AskOne(&survey.Confirm{
if err := survey.AskOne(&survey.Confirm{
Message: "It will overwrite the namespace data in the destination storage, continue?",
Default: false,
}, &confirm); err != nil {
Expand All @@ -32,6 +22,16 @@ func Migrate(ctx context.Context, to map[string]string) error {
return nil
}

meta, err := kv.From(ctx).MigrateTo()
if err != nil {
return errors.Wrap(err, "read data")
}

dest, err := kv.NewWithMap(to)
if err != nil {
return errors.Wrap(err, "create dest storage")
}

if err = dest.MigrateFrom(meta); err != nil {
return errors.Wrap(err, "migrate from")
}
Expand Down

0 comments on commit 52e140f

Please sign in to comment.