diff --git a/src/bin/transfer-crates.rs b/src/bin/transfer-crates.rs index 48e507757bb..1c536612247 100644 --- a/src/bin/transfer-crates.rs +++ b/src/bin/transfer-crates.rs @@ -48,14 +48,14 @@ fn transfer(tx: &postgres::transaction::Transaction) { let from = User::find_by_login(tx, &from).unwrap(); let to = User::find_by_login(tx, &to).unwrap(); - if from.gh_avatar != to.gh_avatar { + if from.gh_id != to.gh_id { println!("===================================================="); println!("WARNING"); println!(""); - println!("this may not be the same github user, different avatar urls"); + println!("this may not be the same github user, different github IDs"); println!(""); - println!("from: {:?}", from.gh_avatar); - println!("to: {:?}", to.gh_avatar); + println!("from: {:?}", from.gh_id); + println!("to: {:?}", to.gh_id); get_confirm("continue?"); } @@ -67,29 +67,28 @@ fn transfer(tx: &postgres::transaction::Transaction) { ); get_confirm("continue"); - let stmt = tx.prepare( "SELECT * FROM crate_owners WHERE owner_id = $1 AND owner_kind = $2", ).unwrap(); let rows = stmt.query(&[&from.id, &(OwnerKind::User as i32)]).unwrap(); + for row in rows.iter() { - let id: i32 = row.get("id"); let krate = Crate::find(tx, row.get("crate_id")).unwrap(); println!("transferring {}", krate.name); let owners = krate.owners_old(tx).unwrap(); if owners.len() != 1 { println!("warning: not exactly one owner for {}", krate.name); } - let n = tx.execute( - "UPDATE crate_owners SET owner_id = $1 - WHERE id $2", - &[&to.id, &id], - ).unwrap(); - assert_eq!(n, 1); } + tx.execute( + "UPDATE crate_owners SET owner_id = $1 + WHERE owner_id = $2", + &[&to.id, &from.id], + ).unwrap(); + get_confirm("commit?"); }