| 1 |
CREATE TABLE post_flags ( |
| 2 |
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| 3 |
post_id UUID NOT NULL REFERENCES posts(id) ON DELETE CASCADE, |
| 4 |
flagger_id UUID NOT NULL REFERENCES users(mnw_account_id), |
| 5 |
reason TEXT NOT NULL CHECK (reason IN ('spam', 'rule_breaking', 'off_topic')), |
| 6 |
detail TEXT, |
| 7 |
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), |
| 8 |
resolved_at TIMESTAMPTZ, |
| 9 |
resolved_by UUID REFERENCES users(mnw_account_id), |
| 10 |
resolution TEXT CHECK (resolution IN ('dismissed', 'removed')), |
| 11 |
UNIQUE (post_id, flagger_id) |
| 12 |
); |
| 13 |
CREATE INDEX idx_post_flags_post ON post_flags(post_id); |
| 14 |
CREATE INDEX idx_post_flags_unresolved ON post_flags(resolved_at) WHERE resolved_at IS NULL; |
| 15 |
|