diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-03-19 05:01:30 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-03-19 05:01:30 +0100 |
| commit | c0041211ed96c5b3a6e8d17a5ec27a8e574cf9de (patch) | |
| tree | 7413938967d04269df8c4447ec3f5a9a3cd89d02 /crates/rocie-server/src/storage/migrate/mod.rs | |
| parent | feat(rocie-server/cli): Make the secret key for identity handling persist-able (diff) | |
| download | server-c0041211ed96c5b3a6e8d17a5ec27a8e574cf9de.zip | |
fix(rocie-server/storage/migrate): Avoid querying `config` table before it exists
We were trying to check the config value /before/ we actually created the initial database schema.
Diffstat (limited to 'crates/rocie-server/src/storage/migrate/mod.rs')
| -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(()) } |
