summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.sqlx/query-58db060ed86a4b4d9aa18078368e99be78ecea12b8600a20068bec69d0836f7c.json12
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml1
-rw-r--r--src/db/mod.rs62
4 files changed, 1 insertions, 81 deletions
diff --git a/.sqlx/query-58db060ed86a4b4d9aa18078368e99be78ecea12b8600a20068bec69d0836f7c.json b/.sqlx/query-58db060ed86a4b4d9aa18078368e99be78ecea12b8600a20068bec69d0836f7c.json
deleted file mode 100644
index 960fdb4..0000000
--- a/.sqlx/query-58db060ed86a4b4d9aa18078368e99be78ecea12b8600a20068bec69d0836f7c.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "db_name": "SQLite",
- "query": "\n update _sqlx_migrations\n set checksum = $1\n where version = $2\n and checksum = $3\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Right": 3
- },
- "nullable": []
- },
- "hash": "58db060ed86a4b4d9aa18078368e99be78ecea12b8600a20068bec69d0836f7c"
-}
diff --git a/Cargo.lock b/Cargo.lock
index f7d3337..199e97c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1232,12 +1232,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
-name = "hex-literal"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
-
-[[package]]
name = "hkdf"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2061,7 +2055,6 @@ dependencies = [
"faker_rand",
"futures",
"headers",
- "hex-literal",
"itertools",
"mime",
"nix",
diff --git a/Cargo.toml b/Cargo.toml
index 1f5fa3d..93531d5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,7 +29,6 @@ chrono = { version = "0.4.39", features = ["serde"] }
clap = { version = "4.5.30", features = ["derive", "env"] }
futures = "0.3.31"
headers = "0.4.0"
-hex-literal = "0.4.1"
itertools = "0.14.0"
mime = "0.3.17"
nix = { version = "0.30.1", features = ["fs"] }
diff --git a/src/db/mod.rs b/src/db/mod.rs
index 99b8986..9a74dcb 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -2,10 +2,9 @@ mod backup;
use std::str::FromStr;
-use hex_literal::hex;
use sqlx::{
error::{DatabaseError, ErrorKind},
- migrate::{Migrate as _, MigrateDatabase as _},
+ migrate::MigrateDatabase as _,
sqlite::{Sqlite, SqliteConnectOptions, SqlitePool, SqlitePoolOptions},
};
@@ -16,19 +15,6 @@ pub async fn prepare(url: &str, backup_url: &str) -> Result<SqlitePool, Error> {
let pool = create(url).await?;
- // First migration of original migration series, from commit
- // 9bd6d9862b1c243def02200bca2cfbf578ad2a2f or earlier.
- reject_migration(&pool, "20240831024047", "login", &hex!("9949D238C4099295EC4BEE734BFDA8D87513B2973DFB895352A11AB01DD46CB95314B7F1B3431B77E3444A165FE3DC28")).await?;
-
- // Original version of this migration was buggy, but didn't require a
- // database reset to fix.
- migration_replaced(
- &pool,
- "20241009031441",
- &hex!("4B5873397C8BA9CFAF49172EE6DE455CD643A27BD71032ECD8EFA7684362FE620A8F6B27D493AF8D9A570C38CC1A6416"),
- &hex!("E5CDEDA38F2BCE4C24A45E58D3BDE3FF2C30B1431C3B01870BB9DEB142E5A200B9C850C3C72A45D352C15D8DB51B8467"),
- ).await?;
-
let backup_pool = create(backup_url).await?;
backup::Backup::from(&pool)
.to(&backup_pool)
@@ -58,50 +44,6 @@ async fn create(database_url: &str) -> sqlx::Result<SqlitePool> {
Ok(pool)
}
-async fn reject_migration(
- pool: &SqlitePool,
- version: &str,
- description: &str,
- checksum: &[u8],
-) -> Result<(), Error> {
- let mut conn = pool.acquire().await?;
- conn.ensure_migrations_table().await?;
- let applied = conn.list_applied_migrations().await?;
-
- for migration in applied {
- if migration.checksum == checksum {
- return Err(Error::Rejected(version.into(), description.into()));
- }
- }
-
- Ok(())
-}
-
-async fn migration_replaced(
- pool: &SqlitePool,
- version: &str,
- original: &[u8],
- replacement: &[u8],
-) -> Result<(), sqlx::Error> {
- let mut conn = pool.acquire().await?;
- conn.ensure_migrations_table().await?;
- sqlx::query!(
- r#"
- update _sqlx_migrations
- set checksum = $1
- where version = $2
- and checksum = $3
- "#,
- replacement,
- version,
- original,
- )
- .execute(&mut *conn)
- .await?;
-
- Ok(())
-}
-
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
@@ -118,8 +60,6 @@ pub enum Error {
Drop(sqlx::Error, sqlx::migrate::MigrateError),
#[error(transparent)]
Migration(#[from] sqlx::migrate::MigrateError),
- #[error("database contains rejected migration {0}:{1}, move it aside")]
- Rejected(String, String),
}
pub trait NotFound: Sized {