Skip to main content

max / makenotwork

721 B · 14 lines History Blame Raw
1 CREATE TABLE community_bans (
2 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3 community_id UUID NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
4 user_id UUID NOT NULL REFERENCES users(mnw_account_id) ON DELETE CASCADE,
5 banned_by UUID NOT NULL REFERENCES users(mnw_account_id),
6 ban_type TEXT NOT NULL CHECK (ban_type IN ('ban', 'mute')),
7 reason TEXT,
8 expires_at TIMESTAMPTZ,
9 created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
10 UNIQUE (community_id, user_id, ban_type)
11 );
12 CREATE INDEX idx_community_bans_lookup ON community_bans (community_id, user_id);
13 CREATE INDEX idx_community_bans_expires ON community_bans (expires_at) WHERE expires_at IS NOT NULL;
14