Fix error when deleting rooms containing projects on refresh

A foreign key violation was causing the server to never delete stale
rooms during `Database::refresh_room` due to having one or more project
records referencing the room.
This commit is contained in:
Antonio Scandurra 2023-02-23 15:54:35 +01:00
parent e74db2d180
commit bbeb33bc7e
3 changed files with 20 additions and 5 deletions

View file

@ -191,6 +191,10 @@ impl Database {
.filter(room_participant::Column::RoomId.eq(room_id))
.exec(&*tx)
.await?;
project::Entity::delete_many()
.filter(project::Column::RoomId.eq(room_id))
.exec(&*tx)
.await?;
room::Entity::delete_by_id(room_id).exec(&*tx).await?;
}