summaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-05 00:15:45 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-05 00:27:29 -0400
commite1551113323d5a496b826d7b0265b1be6235f45c (patch)
tree08f09cac579c954c782e39d5cd02c7ae72f86374 /src/cli.rs
parentb422be184e01b4cc35b9c9a6921379080c24edb3 (diff)
Make a backup of the `.hi` database before applying migrations.
This was motivated by Kit and I both independently discovering that sqlite3 will happily partially apply migrations, leaving the DB in a broken state.
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cli.rs b/src/cli.rs
index d88916a..31dd4ce 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -49,6 +49,10 @@ pub struct Args {
/// Sqlite URL or path for the `hi` database
#[arg(short, long, env, default_value = "sqlite://.hi")]
database_url: String,
+
+ /// Sqlite URL or path for a backup of the `hi` database during upgrades
+ #[arg(short = 'D', long, env, default_value = "sqlite://.hi.backup")]
+ backup_database_url: String,
}
impl Args {
@@ -100,7 +104,7 @@ impl Args {
}
async fn pool(&self) -> Result<SqlitePool, db::Error> {
- db::prepare(&self.database_url).await
+ db::prepare(&self.database_url, &self.backup_database_url).await
}
}