Fix db inconsistencies when deleting a room
Since the euph_trees table can't have any foreign key constraints pointing to the euph_rooms table, deleting a room wouldn't delete that room's trees in euph_trees. Upon reconnecting to the room, those trees would then be displayed as placeholder messages without children.
This commit is contained in:
parent
a2b9f57a09
commit
f430b0efc7
3 changed files with 15 additions and 3 deletions
|
|
@ -472,13 +472,25 @@ impl EuphRequest {
|
|||
}
|
||||
|
||||
fn delete(conn: &mut Connection, room: String) -> rusqlite::Result<()> {
|
||||
conn.execute(
|
||||
let tx = conn.transaction()?;
|
||||
|
||||
tx.execute(
|
||||
"
|
||||
DELETE FROM euph_rooms
|
||||
WHERE room = ?
|
||||
",
|
||||
[room],
|
||||
[&room],
|
||||
)?;
|
||||
|
||||
tx.execute(
|
||||
"
|
||||
DELETE FROM euph_trees
|
||||
WHERE room = ?
|
||||
",
|
||||
[&room],
|
||||
)?;
|
||||
|
||||
tx.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue