mirror of
https://github.com/iyear/tdl
synced 2025-01-07 03:16:41 +08:00
fix(migrate): confirm before migration
This commit is contained in:
parent
21803a9357
commit
52e140f502
@ -11,6 +11,17 @@ import (
|
||||
)
|
||||
|
||||
func Migrate(ctx context.Context, to map[string]string) error {
|
||||
var confirm bool
|
||||
if err := survey.AskOne(&survey.Confirm{
|
||||
Message: "It will overwrite the namespace data in the destination storage, continue?",
|
||||
Default: false,
|
||||
}, &confirm); err != nil {
|
||||
return errors.Wrap(err, "confirm")
|
||||
}
|
||||
if !confirm {
|
||||
return nil
|
||||
}
|
||||
|
||||
meta, err := kv.From(ctx).MigrateTo()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read data")
|
||||
@ -21,17 +32,6 @@ func Migrate(ctx context.Context, to map[string]string) error {
|
||||
return errors.Wrap(err, "create dest storage")
|
||||
}
|
||||
|
||||
var confirm bool
|
||||
if err = survey.AskOne(&survey.Confirm{
|
||||
Message: "It will overwrite the namespace data in the destination storage, continue?",
|
||||
Default: false,
|
||||
}, &confirm); err != nil {
|
||||
return errors.Wrap(err, "confirm")
|
||||
}
|
||||
if !confirm {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err = dest.MigrateFrom(meta); err != nil {
|
||||
return errors.Wrap(err, "migrate from")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user