feat: add reports table schema for preset reporting
This commit is contained in:
@@ -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");
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -64,6 +64,13 @@
|
|||||||
"when": 1777271387867,
|
"when": 1777271387867,
|
||||||
"tag": "0008_slim_jubilee",
|
"tag": "0008_slim_jubilee",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 9,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1777273845181,
|
||||||
|
"tag": "0009_flawless_meltdown",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -7,3 +7,4 @@ export * from "./performanceEntries"
|
|||||||
export * from "./gamePlatformSupport"
|
export * from "./gamePlatformSupport"
|
||||||
export * from "./gameComments"
|
export * from "./gameComments"
|
||||||
export * from "./savedGames"
|
export * from "./savedGames"
|
||||||
|
export * from "./reports"
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import {
|
||||||
|
text,
|
||||||
|
pgEnum,
|
||||||
|
pgTable,
|
||||||
|
timestamp,
|
||||||
|
uniqueIndex,
|
||||||
|
} from "drizzle-orm/pg-core"
|
||||||
|
import { performanceEntries } from "./performanceEntries"
|
||||||
|
import { user } from "./auth"
|
||||||
|
|
||||||
|
export const reportReasonEnum = pgEnum("report_reason", [
|
||||||
|
"inaccurate",
|
||||||
|
"spam",
|
||||||
|
"inappropriate",
|
||||||
|
"other",
|
||||||
|
])
|
||||||
|
|
||||||
|
export const reportStatusEnum = pgEnum("report_status", [
|
||||||
|
"open",
|
||||||
|
"reviewed",
|
||||||
|
"dismissed",
|
||||||
|
])
|
||||||
|
|
||||||
|
export const reports = pgTable("reports", {
|
||||||
|
id: text("id")
|
||||||
|
.primaryKey()
|
||||||
|
.$defaultFn(() => crypto.randomUUID()),
|
||||||
|
entryId: text("entry_id")
|
||||||
|
.notNull()
|
||||||
|
.references(() => performanceEntries.id, { onDelete: "cascade" }),
|
||||||
|
reporterId: text("reporter_id")
|
||||||
|
.notNull()
|
||||||
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
|
reason: reportReasonEnum("reason").notNull(),
|
||||||
|
details: text("details"),
|
||||||
|
status: reportStatusEnum("status").default("open").notNull(),
|
||||||
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
|
}, (table) => [
|
||||||
|
uniqueIndex("reports_entry_reporter_unique").on(table.entryId, table.reporterId),
|
||||||
|
])
|
||||||
Reference in New Issue
Block a user