1+ CREATE TABLE "panel_criterias " (
2+ " id" text PRIMARY KEY NOT NULL ,
3+ " panel_round_id" text NOT NULL ,
4+ " criteria_name" text NOT NULL ,
5+ " max_score" integer DEFAULT 10 NOT NULL
6+ );
7+ -- > statement-breakpoint
8+ CREATE TABLE "panel_round_assignments " (
9+ " id" text PRIMARY KEY NOT NULL ,
10+ " panelist_id" text NOT NULL ,
11+ " team_id" text NOT NULL ,
12+ " panel_round_id" text NOT NULL ,
13+ " raw_total_score" integer ,
14+ " normalized_total_score" double precision ,
15+ CONSTRAINT " panel_round_team_assignment_unique" UNIQUE(" panelist_id" ," team_id" ," panel_round_id" )
16+ );
17+ -- > statement-breakpoint
18+ CREATE TABLE "panel_rounds " (
19+ " id" text PRIMARY KEY NOT NULL ,
20+ " name" text NOT NULL ,
21+ " status" " round_status" DEFAULT ' Draft' NOT NULL
22+ );
23+ -- > statement-breakpoint
24+ CREATE TABLE "panel_scores " (
25+ " id" text PRIMARY KEY NOT NULL ,
26+ " round_assignment_id" text NOT NULL ,
27+ " criteria_id" text NOT NULL ,
28+ " raw_score" integer ,
29+ CONSTRAINT " panel_score_assignment_criteria_unique" UNIQUE(" round_assignment_id" ," criteria_id" )
30+ );
31+ -- > statement-breakpoint
32+ CREATE TABLE "panel_team_round_scores " (
33+ " id" text PRIMARY KEY NOT NULL ,
34+ " team_id" text NOT NULL ,
35+ " round_id" text NOT NULL ,
36+ " raw_total_score" integer ,
37+ " normalized_total_score" double precision ,
38+ " panelist_count" integer DEFAULT 0 NOT NULL ,
39+ CONSTRAINT " panel_team_round_scores_unique" UNIQUE(" team_id" ," round_id" )
40+ );
41+ -- > statement-breakpoint
42+ CREATE TABLE "panelists " (
43+ " id" text PRIMARY KEY NOT NULL ,
44+ " dashboard_user_id" text NOT NULL
45+ );
46+ -- > statement-breakpoint
47+ ALTER TABLE " panel_criterias" ADD CONSTRAINT " panel_criterias_panel_round_id_panel_rounds_id_fk" FOREIGN KEY (" panel_round_id" ) REFERENCES " public" ." panel_rounds" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
48+ ALTER TABLE " panel_round_assignments" ADD CONSTRAINT " panel_round_assignments_panelist_id_panelists_id_fk" FOREIGN KEY (" panelist_id" ) REFERENCES " public" ." panelists" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
49+ ALTER TABLE " panel_round_assignments" ADD CONSTRAINT " panel_round_assignments_team_id_team_id_fk" FOREIGN KEY (" team_id" ) REFERENCES " public" ." team" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
50+ ALTER TABLE " panel_round_assignments" ADD CONSTRAINT " panel_round_assignments_panel_round_id_panel_rounds_id_fk" FOREIGN KEY (" panel_round_id" ) REFERENCES " public" ." panel_rounds" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
51+ ALTER TABLE " panel_scores" ADD CONSTRAINT " panel_scores_round_assignment_id_panel_round_assignments_id_fk" FOREIGN KEY (" round_assignment_id" ) REFERENCES " public" ." panel_round_assignments" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
52+ ALTER TABLE " panel_scores" ADD CONSTRAINT " panel_scores_criteria_id_panel_criterias_id_fk" FOREIGN KEY (" criteria_id" ) REFERENCES " public" ." panel_criterias" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
53+ ALTER TABLE " panel_team_round_scores" ADD CONSTRAINT " panel_team_round_scores_team_id_team_id_fk" FOREIGN KEY (" team_id" ) REFERENCES " public" ." team" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
54+ ALTER TABLE " panel_team_round_scores" ADD CONSTRAINT " panel_team_round_scores_round_id_panel_rounds_id_fk" FOREIGN KEY (" round_id" ) REFERENCES " public" ." panel_rounds" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
55+ ALTER TABLE " panelists" ADD CONSTRAINT " panelists_dashboard_user_id_dashboard_user_id_fk" FOREIGN KEY (" dashboard_user_id" ) REFERENCES " public" ." dashboard_user" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
56+ CREATE INDEX "panel_criteria_round_idx " ON " panel_criterias" USING btree (" panel_round_id" );-- > statement-breakpoint
57+ CREATE INDEX "panel_assignment_round_idx " ON " panel_round_assignments" USING btree (" panel_round_id" );-- > statement-breakpoint
58+ CREATE INDEX "panel_assignments_idx " ON " panel_round_assignments" USING btree (" panelist_id" );-- > statement-breakpoint
59+ CREATE INDEX "panel_assignment_team_idx " ON " panel_round_assignments" USING btree (" team_id" );-- > statement-breakpoint
60+ CREATE INDEX "panel_round_panelist_idx " ON " panel_round_assignments" USING btree (" panel_round_id" ," panelist_id" );-- > statement-breakpoint
61+ CREATE INDEX "panel_round_team_idx " ON " panel_round_assignments" USING btree (" panel_round_id" ," team_id" );-- > statement-breakpoint
62+ CREATE INDEX "panel_score_assignment_idx " ON " panel_scores" USING btree (" round_assignment_id" );-- > statement-breakpoint
63+ CREATE INDEX "panel_score_criteria_idx " ON " panel_scores" USING btree (" criteria_id" );-- > statement-breakpoint
64+ CREATE INDEX "panelist_dashboard_user_idx " ON " panelists" USING btree (" dashboard_user_id" );
0 commit comments