mirror of
https://github.com/usememos/memos.git
synced 2024-12-29 16:42:11 +08:00
fix: prevent copydb to create a fresh memos (#2486)
Prevent copydb to create a fresh memos
This commit is contained in:
parent
c4d27e7a78
commit
35f0861d6e
1 changed files with 7 additions and 0 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue