mirror of
https://github.com/block/buzz.git
synced 2026-10-31 22:41:12 +00:00
Canonical O4 slice: 04_protected_authority Final-tree source: e45553ea65b66631771c16908513f983d3c0b881 Signed-off-by: Cea Stapleton Cordasco <261786559+cea-block@users.noreply.github.com>
23 lines
989 B
SQL
23 lines
989 B
SQL
-- Durable authority boundary for protected audio sessions.
|
|
--
|
|
-- The row records a bounded existing-member admission. It does not create
|
|
-- membership and cannot outlive the finalized access lease.
|
|
|
|
CREATE TABLE audio_session_admissions (
|
|
community_id UUID NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
|
|
admission_id UUID NOT NULL,
|
|
channel_id UUID NOT NULL,
|
|
pubkey BYTEA NOT NULL CHECK (octet_length(pubkey) = 32),
|
|
lease_expires_at TIMESTAMPTZ NOT NULL,
|
|
admitted_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
|
|
PRIMARY KEY (community_id, admission_id),
|
|
CONSTRAINT audio_session_admissions_channel_fk
|
|
FOREIGN KEY (community_id, channel_id)
|
|
REFERENCES channels(community_id, id) ON DELETE CASCADE,
|
|
CONSTRAINT audio_session_admissions_positive_lease
|
|
CHECK (lease_expires_at > admitted_at)
|
|
);
|
|
|
|
CREATE INDEX idx_audio_session_admissions_active
|
|
ON audio_session_admissions (community_id, channel_id, lease_expires_at);
|