Complete backend MVP

This commit is contained in:
gabdevele
2026-06-05 11:56:28 +02:00 Unverified
parent 25c280f38b
commit 5974f01daa
25 changed files with 3468 additions and 1137 deletions
+39
View File
@@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS notifications (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
type VARCHAR(80) NOT NULL,
title VARCHAR(160) NOT NULL,
body TEXT NULL,
report_id BIGINT UNSIGNED NULL,
read_at DATETIME NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT notifications_user_fk FOREIGN KEY (user_id) REFERENCES users(id),
CONSTRAINT notifications_report_fk FOREIGN KEY (report_id) REFERENCES reports(id),
KEY notifications_user_read_created_idx (user_id, read_at, created_at),
KEY notifications_report_idx (report_id)
);
CREATE TABLE IF NOT EXISTS moderation_flags (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
content_type VARCHAR(30) NOT NULL,
report_id BIGINT UNSIGNED NOT NULL,
message_id BIGINT UNSIGNED NULL,
reason VARCHAR(120) NOT NULL,
details TEXT NULL,
status VARCHAR(30) NOT NULL DEFAULT 'OPEN',
created_by_user_id BIGINT UNSIGNED NOT NULL,
resolved_by_user_id BIGINT UNSIGNED NULL,
resolution_note TEXT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
resolved_at DATETIME NULL,
CONSTRAINT moderation_flags_report_fk FOREIGN KEY (report_id) REFERENCES reports(id),
CONSTRAINT moderation_flags_message_fk FOREIGN KEY (message_id) REFERENCES messages(id),
CONSTRAINT moderation_flags_created_by_fk FOREIGN KEY (created_by_user_id) REFERENCES users(id),
CONSTRAINT moderation_flags_resolved_by_fk FOREIGN KEY (resolved_by_user_id) REFERENCES users(id),
KEY moderation_flags_status_created_idx (status, created_at),
KEY moderation_flags_report_idx (report_id),
KEY moderation_flags_message_idx (message_id)
);
ALTER TABLE reward_events
ADD UNIQUE KEY reward_events_report_reason_unique (report_id, reason);