Perform last member removal check on the database.

This commit is contained in:
2026-10-12 18:05:10 +02:00
parent 6729dd060b
commit 2b37fd6ebc
11 changed files with 102 additions and 123 deletions
-28
View File
@@ -62,34 +62,6 @@ where
.map_err(DatabaseError::from)
}
/// Like [`get_by_id`], but also locks the account row until the end of the transaction, so the
/// executor must be a transaction. Callers locking the same account are serialized, while
/// inserting members into the account is not blocked.
pub async fn get_by_id_locking<'e, E>(
executor: E,
user_id: Uuid,
id: Uuid,
) -> Result<Option<AccountRow>, DatabaseError>
where
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
{
sqlx::query_as!(
AccountRow,
r#"
SELECT id, name
FROM accounts
WHERE id IN (SELECT id FROM accessible_accounts($1))
AND id = $2
FOR NO KEY UPDATE
"#,
user_id,
id,
)
.fetch_optional(executor)
.await
.map_err(DatabaseError::from)
}
pub async fn get_by_ids<'e, E>(
executor: E,
user_id: Uuid,