buzz-db: require an active community on main's newer community UPDATEs

Main added three communities UPDATEs after this PR was written
(artifact_policy_modified_at in update_channel_on and soft_delete_on, and
set_community_nip_fi_policy). Each runs under admission, so the runtime is
already safe; the active predicate makes them satisfy the single-table
guard policy like every other community writer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
This commit is contained in:
Luke Tornquist
2026-11-10 07:58:51 -08:00
parent 36af50e01a
commit cea7e1221b
2 changed files with 11 additions and 6 deletions

View File

@@ -1417,7 +1417,8 @@ async fn update_channel_on(
}
if policy_changed {
sqlx::query(
"UPDATE communities SET artifact_policy_modified_at=clock_timestamp() WHERE id=$1",
"UPDATE communities SET artifact_policy_modified_at=clock_timestamp() \
WHERE id=$1 AND deletion_state = 'active'",
)
.bind(community_id.as_uuid())
.execute(tx.conn())
@@ -1838,10 +1839,13 @@ async fn soft_delete_on(w: &mut ChannelSettingsWriter<'_>) -> Result<()> {
.bind(channel_id)
.execute(w.tx.conn())
.await?;
sqlx::query("UPDATE communities SET artifact_policy_modified_at=clock_timestamp() WHERE id=$1")
.bind(community_id.as_uuid())
.execute(w.tx.conn())
.await?;
sqlx::query(
"UPDATE communities SET artifact_policy_modified_at=clock_timestamp() \
WHERE id=$1 AND deletion_state = 'active'",
)
.bind(community_id.as_uuid())
.execute(w.tx.conn())
.await?;
Ok(())
}

View File

@@ -412,7 +412,8 @@ impl Db {
.await?;
let generation = old_generation + 1;
sqlx::query(
"UPDATE communities SET policy_generation = $2, requires_nip_fi = $3 WHERE id = $1",
"UPDATE communities SET policy_generation = $2, requires_nip_fi = $3 \
WHERE id = $1 AND deletion_state = 'active'",
)
.bind(request.community_id)
.bind(generation)