mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
21 lines
924 B
SQL
21 lines
924 B
SQL
-- ── Channel members ───────────────────────────────────────────────────────────
|
|
-- Conformance: "Channels and channel membership". PK leads with community_id.
|
|
|
|
CREATE TABLE channel_members (
|
|
community_id UUID NOT NULL REFERENCES communities(id),
|
|
channel_id UUID NOT NULL,
|
|
pubkey BYTEA NOT NULL,
|
|
role member_role NOT NULL DEFAULT 'member',
|
|
joined_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
invited_by BYTEA,
|
|
removed_at TIMESTAMPTZ,
|
|
removed_by BYTEA,
|
|
hidden_at TIMESTAMPTZ,
|
|
PRIMARY KEY (community_id, channel_id, pubkey),
|
|
FOREIGN KEY (community_id, channel_id)
|
|
REFERENCES channels (community_id, id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE INDEX idx_channel_members_pubkey ON channel_members (community_id, pubkey)
|
|
WHERE removed_at IS NULL;
|