21 lines
1.3 KiB
SQL
21 lines
1.3 KiB
SQL
CREATE TYPE "public"."suggestion_status" AS ENUM('pending', 'approved', 'rejected');--> statement-breakpoint
|
|
CREATE TABLE "community_suggestions" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"game_id" text NOT NULL,
|
|
"user_id" text NOT NULL,
|
|
"field_name" text NOT NULL,
|
|
"current_value" text,
|
|
"proposed_value" text NOT NULL,
|
|
"reason" text,
|
|
"status" "suggestion_status" DEFAULT 'pending' NOT NULL,
|
|
"reviewed_by" text,
|
|
"reviewed_at" timestamp,
|
|
"review_note" text,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "community_suggestions" ADD CONSTRAINT "community_suggestions_game_id_games_id_fk" FOREIGN KEY ("game_id") REFERENCES "public"."games"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "community_suggestions" ADD CONSTRAINT "community_suggestions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "community_suggestions" ADD CONSTRAINT "community_suggestions_reviewed_by_user_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "community_suggestions_game_field_user" ON "community_suggestions" USING btree ("game_id","field_name","user_id"); |