Unverified Commit 35f0861d authored by Athurg Gooth's avatar Athurg Gooth Committed by GitHub

fix: prevent copydb to create a fresh memos (#2486)

Prevent copydb to create a fresh memos
parent c4d27e7a
...@@ -59,6 +59,13 @@ func copydb(fromProfile, toProfile *_profile.Profile) error { ...@@ -59,6 +59,13 @@ func copydb(fromProfile, toProfile *_profile.Profile) error {
return errors.Wrap(err, "fail to create `to` driver") return errors.Wrap(err, "fail to create `to` driver")
} }
// Check if `to` driver has been created before
if history, err := toDriver.FindMigrationHistoryList(ctx, nil); err != nil {
return errors.New("fail to check migration history of `to` driver")
} else if len(history) == 0 {
return errors.New("migration history of `to` driver should not be empty")
}
if err := toDriver.Migrate(ctx); err != nil { if err := toDriver.Migrate(ctx); err != nil {
return errors.Wrap(err, "fail to migrate db") return errors.Wrap(err, "fail to migrate db")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment