24 lines
1.2 KiB
MySQL
24 lines
1.2 KiB
MySQL
|
|
ALTER TYPE "public"."simulator_type" ADD VALUE 'tennis_qualifying_points';--> statement-breakpoint
|
||
|
|
CREATE TABLE IF NOT EXISTS "participant_surface_elos" (
|
||
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||
|
|
"participant_id" uuid NOT NULL,
|
||
|
|
"sports_season_id" uuid NOT NULL,
|
||
|
|
"elo_hard" integer,
|
||
|
|
"elo_clay" integer,
|
||
|
|
"elo_grass" integer,
|
||
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
||
|
|
);
|
||
|
|
--> statement-breakpoint
|
||
|
|
DO $$ BEGIN
|
||
|
|
ALTER TABLE "participant_surface_elos" ADD CONSTRAINT "participant_surface_elos_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_surface_elos" ADD CONSTRAINT "participant_surface_elos_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_surface_elos_unique" ON "participant_surface_elos" USING btree ("participant_id","sports_season_id");
|