diff --git a/src/database/models/project_item.rs b/src/database/models/project_item.rs index 5c8c19263..147843187 100644 --- a/src/database/models/project_item.rs +++ b/src/database/models/project_item.rs @@ -394,12 +394,6 @@ impl Project { .fetch_optional(&mut *transaction) .await?; - if let Some(thread_id) = thread_id { - if let Some(id) = thread_id.thread_id { - crate::database::models::Thread::remove_full(ThreadId(id), transaction).await?; - } - } - sqlx::query!( " DELETE FROM mod_follows @@ -527,6 +521,12 @@ impl Project { .execute(&mut *transaction) .await?; + if let Some(thread_id) = thread_id { + if let Some(id) = thread_id.thread_id { + crate::database::models::Thread::remove_full(ThreadId(id), transaction).await?; + } + } + Ok(Some(())) } diff --git a/src/database/models/report_item.rs b/src/database/models/report_item.rs index 11775d08e..bd352a740 100644 --- a/src/database/models/report_item.rs +++ b/src/database/models/report_item.rs @@ -135,12 +135,6 @@ impl Report { .fetch_optional(&mut *transaction) .await?; - if let Some(thread_id) = thread_id { - if let Some(id) = thread_id.thread_id { - crate::database::models::Thread::remove_full(ThreadId(id), transaction).await?; - } - } - sqlx::query!( " DELETE FROM reports WHERE id = $1 @@ -150,6 +144,12 @@ impl Report { .execute(&mut *transaction) .await?; + if let Some(thread_id) = thread_id { + if let Some(id) = thread_id.thread_id { + crate::database::models::Thread::remove_full(ThreadId(id), transaction).await?; + } + } + Ok(Some(())) } }