diff --git a/src/db/delete.rs b/src/db/delete.rs index d73210872..26c71137b 100644 --- a/src/db/delete.rs +++ b/src/db/delete.rs @@ -49,9 +49,8 @@ fn get_id(conn: &Connection, name: &str) -> Result { // metaprogramming! // WARNING: these must be hard-coded and NEVER user input. -const METADATA: [(&str, &str); 5] = [ +const METADATA: &[(&str, &str)] = &[ ("author_rels", "rid"), - ("owner_rels", "cid"), ("keyword_rels", "rid"), ("builds", "rid"), ("compression_rels", "release"), @@ -60,7 +59,7 @@ const METADATA: [(&str, &str); 5] = [ fn delete_version_from_database(conn: &Connection, name: &str, version: &str) -> Result<(), Error> { let crate_id = get_id(conn, name)?; let transaction = conn.transaction()?; - for &(table, column) in &METADATA { + for &(table, column) in METADATA { transaction.execute( &format!("DELETE FROM {} WHERE {} IN (SELECT id FROM releases WHERE crate_id = $1 AND version = $2)", table, column), &[&crate_id, &version], @@ -96,7 +95,7 @@ fn delete_crate_from_database(conn: &Connection, name: &str, crate_id: i32) -> R "DELETE FROM sandbox_overrides WHERE crate_name = $1", &[&name], )?; - for &(table, column) in &METADATA { + for &(table, column) in METADATA { transaction.execute( &format!( "DELETE FROM {} WHERE {} IN (SELECT id FROM releases WHERE crate_id = $1)", @@ -105,6 +104,7 @@ fn delete_crate_from_database(conn: &Connection, name: &str, crate_id: i32) -> R &[&crate_id], )?; } + transaction.execute("DELETE FROM owner_rels WHERE cid = $1;", &[&crate_id])?; transaction.execute("DELETE FROM releases WHERE crate_id = $1;", &[&crate_id])?; transaction.execute("DELETE FROM crates WHERE id = $1;", &[&crate_id])?;