A deleted DM blocks reopening a DM for the same participants
Summary
A DM that was deleted through the API can never be reopened for the same participants. open_dm fails and the pair stays blocked until someone edits the database by hand.
Reproduction
open_dmfor participants A and B (creates a DM).- Delete that DM (
soft_delete_channel, i.e.DELETE_GROUPkind 9008 on the DM). open_dmagain for A and B.
Step 3 fails with a DM with these members already exists, although no live DM exists for the pair.
Cause
On main (a79cbb4664c175a4b69026aec610ea549bdfcb2c):
crates/buzz-db/src/store/channel.rs:1978:soft_delete_ononly setsdeleted_at.participant_hashstays on the row.crates/buzz-db/src/store/dm.rs:203-205:find_dm_inmatchesparticipant_hash = $2 AND deleted_at IS NULL, so the deleted DM is not found.crates/buzz-db/src/store/dm.rs:385-396:create_dmtherefore inserts a new row with the same hash and loses on the unique violation (23505), then looks again, finds nothing live, and reports the conflict.migrations/0001_initial_schema.sql:104-105(andschema/tables/public/channels.sql:52-53):idx_channels_dm_hashisUNIQUE (community_id, participant_hash) WHERE participant_hash IS NOT NULL. It still covers the deleted row.
Proposal
Make the index partial over live channels too: WHERE participant_hash IS NOT NULL AND deleted_at IS NULL. No data changes, no new objects, and the new index is weaker than the old one, so an older relay keeps working against the migrated database. A migration, the schema file and a Postgres test follow as a PR.
An alternative would be to clear participant_hash in soft_delete_on. That leaves already-deleted rows blocking their pairs and would need a data backfill, so the index change looks simpler.
Note
We have run this index on a self-hosted relay since 2026-10-11: reopening a deleted DM creates a new one (created: true).