Fix: Run migrations after importing backup again (#3006)

As of #2980, the migrations were not run after importing a backup. This lead to errors like "Failed to send message: no such table: smtp" if you imported a backup from a previous DC version.
This commit is contained in:
Hocuri
2022-01-24 16:36:28 +01:00
committed by GitHub
parent 2446fc44ad
commit 5f939c3123
3 changed files with 12 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## Unreleased
fix: run migrations on backup import #3006
## 1.71.0 ## 1.71.0
### API Changes ### API Changes

View File

@@ -423,7 +423,8 @@ async fn imex_inner(
export_backup(context, path, passphrase.unwrap_or_default()).await export_backup(context, path, passphrase.unwrap_or_default()).await
} }
ImexMode::ImportBackup => { ImexMode::ImportBackup => {
import_backup(context, path, passphrase.unwrap_or_default()).await import_backup(context, path, passphrase.unwrap_or_default()).await?;
context.sql.run_migrations(context).await
} }
} }
} }

View File

@@ -215,6 +215,12 @@ impl Sql {
conn.pragma_update(None, "synchronous", &"NORMAL".to_string())?; conn.pragma_update(None, "synchronous", &"NORMAL".to_string())?;
} }
self.run_migrations(context).await?;
Ok(())
}
pub async fn run_migrations(&self, context: &Context) -> Result<()> {
// (1) update low-level database structure. // (1) update low-level database structure.
// this should be done before updates that use high-level objects that // this should be done before updates that use high-level objects that
// rely themselves on the low-level structure. // rely themselves on the low-level structure.