ALTER TABLE "participant_expected_values" RENAME TO "season_participant_expected_values";--> statement-breakpoint ALTER TABLE "participant_qualifying_totals" RENAME TO "season_participant_qualifying_totals";--> statement-breakpoint ALTER TABLE "participant_results" RENAME TO "season_participant_results";--> statement-breakpoint ALTER TABLE "participant_surface_elos" RENAME TO "season_participant_surface_elos";--> statement-breakpoint ALTER TABLE "participants" RENAME TO "season_participants";--> statement-breakpoint ALTER TABLE "event_results" RENAME COLUMN "participant_id" TO "season_participant_id";--> statement-breakpoint ALTER TABLE "cs2_major_stage_results" DROP CONSTRAINT IF EXISTS "cs2_major_stage_results_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "draft_picks" DROP CONSTRAINT IF EXISTS "draft_picks_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "draft_queue" DROP CONSTRAINT IF EXISTS "draft_queue_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "event_results" DROP CONSTRAINT IF EXISTS "event_results_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "group_stage_matches" DROP CONSTRAINT IF EXISTS "group_stage_matches_participant1_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "group_stage_matches" DROP CONSTRAINT IF EXISTS "group_stage_matches_participant2_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "participant_ev_snapshots" DROP CONSTRAINT IF EXISTS "participant_ev_snapshots_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_expected_values" DROP CONSTRAINT IF EXISTS "participant_expected_values_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_expected_values" DROP CONSTRAINT IF EXISTS "participant_expected_values_sports_season_id_sports_seasons_id_fk"; --> statement-breakpoint ALTER TABLE "participant_golf_skills" DROP CONSTRAINT IF EXISTS "participant_golf_skills_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_qualifying_totals" DROP CONSTRAINT IF EXISTS "participant_qualifying_totals_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_qualifying_totals" DROP CONSTRAINT IF EXISTS "participant_qualifying_totals_sports_season_id_sports_seasons_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_results" DROP CONSTRAINT IF EXISTS "participant_results_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_results" DROP CONSTRAINT IF EXISTS "participant_results_sports_season_id_sports_seasons_id_fk"; --> statement-breakpoint ALTER TABLE "participant_season_results" DROP CONSTRAINT IF EXISTS "participant_season_results_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_surface_elos" DROP CONSTRAINT IF EXISTS "participant_surface_elos_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "season_participant_surface_elos" DROP CONSTRAINT IF EXISTS "participant_surface_elos_sports_season_id_sports_seasons_id_fk"; --> statement-breakpoint ALTER TABLE "season_participants" DROP CONSTRAINT IF EXISTS "participants_sports_season_id_sports_seasons_id_fk"; --> statement-breakpoint ALTER TABLE "playoff_match_games" DROP CONSTRAINT IF EXISTS "playoff_match_games_winner_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "playoff_match_odds" DROP CONSTRAINT IF EXISTS "playoff_match_odds_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "playoff_matches" DROP CONSTRAINT IF EXISTS "playoff_matches_participant1_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "playoff_matches" DROP CONSTRAINT IF EXISTS "playoff_matches_participant2_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "playoff_matches" DROP CONSTRAINT IF EXISTS "playoff_matches_winner_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "playoff_matches" DROP CONSTRAINT IF EXISTS "playoff_matches_loser_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "regular_season_standings" DROP CONSTRAINT IF EXISTS "regular_season_standings_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "tournament_group_members" DROP CONSTRAINT IF EXISTS "tournament_group_members_participant_id_participants_id_fk"; --> statement-breakpoint ALTER TABLE "watchlist" DROP CONSTRAINT IF EXISTS "watchlist_participant_id_participants_id_fk"; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "cs2_major_stage_results" ADD CONSTRAINT "cs2_major_stage_results_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "draft_picks" ADD CONSTRAINT "draft_picks_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "draft_queue" ADD CONSTRAINT "draft_queue_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "event_results" ADD CONSTRAINT "event_results_season_participant_id_season_participants_id_fk" FOREIGN KEY ("season_participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "group_stage_matches" ADD CONSTRAINT "group_stage_matches_participant1_id_season_participants_id_fk" FOREIGN KEY ("participant1_id") REFERENCES "public"."season_participants"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "group_stage_matches" ADD CONSTRAINT "group_stage_matches_participant2_id_season_participants_id_fk" FOREIGN KEY ("participant2_id") REFERENCES "public"."season_participants"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "participant_ev_snapshots" ADD CONSTRAINT "participant_ev_snapshots_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_expected_values" ADD CONSTRAINT "season_participant_expected_values_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_expected_values" ADD CONSTRAINT "season_participant_expected_values_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 DO $$ BEGIN ALTER TABLE "participant_golf_skills" ADD CONSTRAINT "participant_golf_skills_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_qualifying_totals" ADD CONSTRAINT "season_participant_qualifying_totals_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_qualifying_totals" ADD CONSTRAINT "season_participant_qualifying_totals_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 DO $$ BEGIN ALTER TABLE "season_participant_results" ADD CONSTRAINT "season_participant_results_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_results" ADD CONSTRAINT "season_participant_results_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 DO $$ BEGIN ALTER TABLE "participant_season_results" ADD CONSTRAINT "participant_season_results_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_surface_elos" ADD CONSTRAINT "season_participant_surface_elos_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "season_participant_surface_elos" ADD CONSTRAINT "season_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 DO $$ BEGIN ALTER TABLE "season_participants" ADD CONSTRAINT "season_participants_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 DO $$ BEGIN ALTER TABLE "playoff_match_games" ADD CONSTRAINT "playoff_match_games_winner_id_season_participants_id_fk" FOREIGN KEY ("winner_id") REFERENCES "public"."season_participants"("id") ON DELETE set null ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "playoff_match_odds" ADD CONSTRAINT "playoff_match_odds_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "playoff_matches" ADD CONSTRAINT "playoff_matches_participant1_id_season_participants_id_fk" FOREIGN KEY ("participant1_id") REFERENCES "public"."season_participants"("id") ON DELETE set null ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "playoff_matches" ADD CONSTRAINT "playoff_matches_participant2_id_season_participants_id_fk" FOREIGN KEY ("participant2_id") REFERENCES "public"."season_participants"("id") ON DELETE set null ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "playoff_matches" ADD CONSTRAINT "playoff_matches_winner_id_season_participants_id_fk" FOREIGN KEY ("winner_id") REFERENCES "public"."season_participants"("id") ON DELETE set null ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "playoff_matches" ADD CONSTRAINT "playoff_matches_loser_id_season_participants_id_fk" FOREIGN KEY ("loser_id") REFERENCES "public"."season_participants"("id") ON DELETE set null ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "regular_season_standings" ADD CONSTRAINT "regular_season_standings_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "tournament_group_members" ADD CONSTRAINT "tournament_group_members_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN ALTER TABLE "watchlist" ADD CONSTRAINT "watchlist_participant_id_season_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."season_participants"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;