Skip to content

Disable name trigger temporarily #699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/bin/delete-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,29 @@ fn delete(tx: &postgres::transaction::Transaction) {
&[&krate.id]).unwrap();
println!(" {} deleted", n);

println!("disabling reserved crate name trigger");
let _ = tx.execute("ALTER TABLE crates DISABLE TRIGGER trigger_ensure_crate_name_not_reserved;",
&[]).unwrap();

println!("deleting crate keyword connections");
let n = tx.execute("DELETE FROM crates_keywords WHERE crate_id = $1",
&[&krate.id]).unwrap();
println!(" {} deleted", n);

println!("deleting crate category connections");
let n = tx.execute("DELETE FROM crates_categories WHERE crate_id = $1",
&[&krate.id]).unwrap();
println!(" {} deleted", n);

println!("enabling reserved crate name trigger");
let _ = tx.execute("ALTER TABLE crates ENABLE TRIGGER trigger_ensure_crate_name_not_reserved;",
&[]).unwrap();

println!("deleting crate badges");
let n = tx.execute("DELETE FROM badges WHERE crate_id = $1",
&[&krate.id]).unwrap();
println!(" {} deleted", n);

println!("deleting the crate");
let n = tx.execute("DELETE FROM crates WHERE id = $1",
&[&krate.id]).unwrap();
Expand Down