Skip to main content

max / makenotwork

1.0 KB · 24 lines History Blame Raw
1 -- Community moderation state machine.
2 --
3 -- Distinct from `suspended_at` (platform-admin action). This is community-level
4 -- moderation by owners/mods/superadmin.
5 --
6 -- States:
7 -- active — normal operation (default)
8 -- restricted — block new thread creation for non-mods (existing threads still accept replies)
9 -- frozen — read-only for everyone except mods doing mod actions
10 -- archived — frozen + hidden from default community listings; surfaces under
11 -- an explicit archived filter; reactivation = set back to active
12 --
13 -- Authorization for transitions: community Owner/Moderator OR platform admin.
14
15 ALTER TABLE communities
16 ADD COLUMN state TEXT NOT NULL DEFAULT 'active'
17 CHECK (state IN ('active', 'restricted', 'frozen', 'archived'));
18
19 -- Partial index for the archived filter view — most communities are active, so
20 -- a partial index keeps the listing query cheap.
21 CREATE INDEX IF NOT EXISTS idx_communities_archived
22 ON communities (name)
23 WHERE state = 'archived';
24