fix: ensure we cleanup all tables when deleting (#2191)

This commit is contained in:
Ellie Huxtable 2024-06-24 16:46:19 +01:00 committed by GitHub
parent 67d64ec4b3
commit 9e36f63c6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -401,24 +401,36 @@ impl Database for Postgres {
.await
.map_err(fix_error)?;
sqlx::query("delete from users where id = $1")
.bind(u.id)
.execute(&self.pool)
.await
.map_err(fix_error)?;
sqlx::query("delete from history where user_id = $1")
.bind(u.id)
.execute(&self.pool)
.await
.map_err(fix_error)?;
sqlx::query("delete from store where user_id = $1")
.bind(u.id)
.execute(&self.pool)
.await
.map_err(fix_error)?;
sqlx::query("delete from user_verification_token where user_id = $1")
.bind(u.id)
.execute(&self.pool)
.await
.map_err(fix_error)?;
sqlx::query("delete from total_history_count_user where user_id = $1")
.bind(u.id)
.execute(&self.pool)
.await
.map_err(fix_error)?;
sqlx::query("delete from users where id = $1")
.bind(u.id)
.execute(&self.pool)
.await
.map_err(fix_error)?;
Ok(())
}