diff options
| author | Kit La Touche <kit@transneptune.net> | 2024-10-10 13:26:15 -0400 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2024-10-10 13:26:15 -0400 |
| commit | 03f8d9ad603a4e523a0e2a0e60ad62c8725f0875 (patch) | |
| tree | b01543c0c2dadbd4be17320d47fc2e3d2fdb280d /src/db | |
| parent | efae871b1bdb1e01081a44218281950cf0177f3b (diff) | |
| parent | d173bc08f2b699f58c8cca752ff688ad46f33ced (diff) | |
Merge branch 'main' into wip/path-routing-for-channels
Diffstat (limited to 'src/db')
| -rw-r--r-- | src/db/mod.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index bbaec7d..b9c59ef 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -28,6 +28,8 @@ pub async fn prepare(url: &str, backup_url: &str) -> Result<SqlitePool, Error> { if let Err(migrate_error) = sqlx::migrate!().run(&pool).await { if let Err(restore_error) = backup::Backup::from(&backup_pool).to(&pool).backup().await { Err(Error::Restore(restore_error, migrate_error))?; + } else if let Err(drop_error) = Sqlite::drop_database(backup_url).await { + Err(Error::Drop(drop_error, migrate_error))?; } else { Err(migrate_error)?; }; @@ -77,8 +79,12 @@ pub enum Error { /// Failure due to a database backup error. See [`backup::Error`]. #[error(transparent)] Backup(#[from] backup::Error), - #[error("backing out failed migration also failed: {0} ({1})")] + #[error("migration failed: {1}\nrestoring backup failed: {0}")] Restore(backup::Error, sqlx::migrate::MigrateError), + #[error( + "migration failed: {1}\nrestoring from backup succeeded, but deleting backup failed: {0}" + )] + Drop(sqlx::Error, sqlx::migrate::MigrateError), /// Failure due to a database migration error. See /// [`sqlx::migrate::MigrateError`]. #[error(transparent)] |
