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

Prevent copydb to create a fresh memos
This commit is contained in:
Athurg Gooth 2023-11-07 13:53:53 +08:00 committed by GitHub
parent c4d27e7a78
commit 35f0861d6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,13 @@ func copydb(fromProfile, toProfile *_profile.Profile) error {
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 {
return errors.Wrap(err, "fail to migrate db")
}