diff options
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/rocie-server/src/storage/migrate/mod.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/crates/rocie-server/src/storage/migrate/mod.rs b/crates/rocie-server/src/storage/migrate/mod.rs index 5c81580..6044440 100644 --- a/crates/rocie-server/src/storage/migrate/mod.rs +++ b/crates/rocie-server/src/storage/migrate/mod.rs @@ -26,7 +26,7 @@ macro_rules! make_upgrade { sqlx::raw_sql(include_str!($sql_name)) .execute(&mut *tx) .await - .map_err(|err| update::Error::SqlUpdate(err))?; + .map_err(update::Error::SqlUpdate)?; set_db_version( &mut tx, @@ -44,9 +44,7 @@ macro_rules! make_upgrade { new_version: $new_version, })?; - tx.commit() - .await - .map_err(|err| update::Error::TxnCommit(err))?; + tx.commit().await.map_err(update::Error::TxnCommit)?; // NOTE: This is needed, so that sqlite "sees" our changes to the table // without having to reconnect. <2025-02-18> @@ -308,12 +306,6 @@ pub(crate) mod get_db_version { pub(crate) async fn migrate_db(app: &App) -> Result<(), migrate_db::Error> { let current_version = get_version(app).await?; - if app.db_version_at_start.get().is_none() { - app.db_version_at_start - .set(current_version) - .expect("the cell to be unititialized, we checked"); - } - if app.db_version_at_start.get() == Some(&DbVersion::Empty) { // We cannot run this code in the normal update function, because for the empty db, there // is no way to know if we want defaults. @@ -336,6 +328,12 @@ pub(crate) async fn migrate_db(app: &App) -> Result<(), migrate_db::Error> { current_version.update(app).await?; + if app.db_version_at_start.get().is_none() { + app.db_version_at_start + .set(current_version) + .expect("the cell to be unititialized, we checked"); + } + Ok(()) } |
