forked from zolfagharipour/Matcha
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path009_reports.sql
More file actions
44 lines (39 loc) · 1.06 KB
/
009_reports.sql
File metadata and controls
44 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
CREATE TABLE IF NOT EXISTS reports (
id INT PRIMARY KEY AUTO_INCREMENT,
reporter_id INT NOT NULL,
reported_id INT NOT NULL,
reason ENUM(
'spam',
'harassment',
'inappropriate_content',
'fake_profile',
'hate_speech',
'scam_or_fraud',
'other'
) NOT NULL DEFAULT 'other',
description TEXT DEFAULT NULL,
status ENUM(
'pending',
'reviewed',
'action_taken',
'dismissed'
) NOT NULL DEFAULT 'pending',
reviewed_by_id INT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_reports_status (status),
INDEX idx_reports_reported (reported_id),
INDEX idx_reports_reporter (reporter_id),
CONSTRAINT fk_reports_reporter
FOREIGN KEY (reporter_id)
REFERENCES users(id)
ON DELETE CASCADE,
CONSTRAINT fk_reports_reported
FOREIGN KEY (reported_id)
REFERENCES users(id)
ON DELETE CASCADE,
CONSTRAINT fk_reports_reviewer
FOREIGN KEY (reviewed_by_id)
REFERENCES users(id)
ON DELETE SET NULL
);