26 lines
1.2 KiB
MySQL
26 lines
1.2 KiB
MySQL
|
|
CREATE TABLE IF NOT EXISTS "participant_golf_skills" (
|
||
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||
|
|
"participant_id" uuid NOT NULL,
|
||
|
|
"sports_season_id" uuid NOT NULL,
|
||
|
|
"sg_total" numeric(5, 2),
|
||
|
|
"datagolf_rank" integer,
|
||
|
|
"masters_odds" integer,
|
||
|
|
"us_open_odds" integer,
|
||
|
|
"open_championship_odds" integer,
|
||
|
|
"pga_championship_odds" integer,
|
||
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
||
|
|
);
|
||
|
|
--> statement-breakpoint
|
||
|
|
DO $$ BEGIN
|
||
|
|
ALTER TABLE "participant_golf_skills" ADD CONSTRAINT "participant_golf_skills_participant_id_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."participants"("id") ON DELETE cascade ON UPDATE no action;
|
||
|
|
EXCEPTION
|
||
|
|
WHEN duplicate_object THEN null;
|
||
|
|
END $$;
|
||
|
|
--> statement-breakpoint
|
||
|
|
DO $$ BEGIN
|
||
|
|
ALTER TABLE "participant_golf_skills" ADD CONSTRAINT "participant_golf_skills_sports_season_id_sports_seasons_id_fk" FOREIGN KEY ("sports_season_id") REFERENCES "public"."sports_seasons"("id") ON DELETE cascade ON UPDATE no action;
|
||
|
|
EXCEPTION
|
||
|
|
WHEN duplicate_object THEN null;
|
||
|
|
END $$;
|
||
|
|
--> statement-breakpoint
|
||
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "participant_golf_skills_unique" ON "participant_golf_skills" USING btree ("participant_id","sports_season_id");
|