summaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 8b39451..620ba9d 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 {
@@ -99,8 +103,8 @@ impl Args {
(self.address.as_str(), self.port)
}
- async fn pool(&self) -> sqlx::Result<SqlitePool> {
- db::prepare(&self.database_url).await
+ async fn pool(&self) -> Result<SqlitePool, db::Error> {
+ db::prepare(&self.database_url, &self.backup_database_url).await
}
}
@@ -127,9 +131,6 @@ fn started_msg(listener: &net::TcpListener) -> io::Result<String> {
pub enum Error {
/// Failure due to `io::Error`. See [`io::Error`].
IoError(#[from] io::Error),
- /// Failure due to a database error. See [`sqlx::Error`].
- DatabaseError(#[from] sqlx::Error),
- /// Failure due to a database migration error. See
- /// [`sqlx::migrate::MigrateError`].
- MigrateError(#[from] sqlx::migrate::MigrateError),
+ /// Failure due to a database initialization error. See [`db::Error`].
+ Database(#[from] db::Error),
}