feat: add reports table schema for preset reporting

This commit is contained in:
2026-04-27 15:30:51 +08:00
parent 5087f3370d
commit b94c29da61
5 changed files with 1691 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
CREATE TYPE "public"."report_reason" AS ENUM('inaccurate', 'spam', 'inappropriate', 'other');--> statement-breakpoint
CREATE TYPE "public"."report_status" AS ENUM('open', 'reviewed', 'dismissed');--> statement-breakpoint
CREATE TABLE "reports" (
"id" text PRIMARY KEY NOT NULL,
"entry_id" text NOT NULL,
"reporter_id" text NOT NULL,
"reason" "report_reason" NOT NULL,
"details" text,
"status" "report_status" DEFAULT 'open' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "reports" ADD CONSTRAINT "reports_entry_id_performance_entries_id_fk" FOREIGN KEY ("entry_id") REFERENCES "public"."performance_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "reports" ADD CONSTRAINT "reports_reporter_id_user_id_fk" FOREIGN KEY ("reporter_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "reports_entry_reporter_unique" ON "reports" USING btree ("entry_id","reporter_id");