fix: add cascade delete rules for tournament matches and related data
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "bracket_matchups" DROP CONSTRAINT "bracket_matchups_matchId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "elo_snapshots" DROP CONSTRAINT "elo_snapshots_matchId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "matches" DROP CONSTRAINT "matches_eventId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "partnership_games" DROP CONSTRAINT "partnership_games_matchId_fkey";
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "bracket_matchups" ADD CONSTRAINT "bracket_matchups_matchId_fkey" FOREIGN KEY ("matchId") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "matches" ADD CONSTRAINT "matches_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "events"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "elo_snapshots" ADD CONSTRAINT "elo_snapshots_matchId_fkey" FOREIGN KEY ("matchId") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "partnership_games" ADD CONSTRAINT "partnership_games_matchId_fkey" FOREIGN KEY ("matchId") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -148,7 +148,7 @@ model BracketMatchup {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
event Event @relation(fields: [eventId], references: [id])
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
match Match? @relation(fields: [matchId], references: [id])
|
match Match? @relation(fields: [matchId], references: [id], onDelete: Cascade)
|
||||||
round TournamentRound @relation(fields: [roundId], references: [id])
|
round TournamentRound @relation(fields: [roundId], references: [id])
|
||||||
team1 Team? @relation("BracketTeam1", fields: [team1Id], references: [id])
|
team1 Team? @relation("BracketTeam1", fields: [team1Id], references: [id])
|
||||||
team2 Team? @relation("BracketTeam2", fields: [team2Id], references: [id])
|
team2 Team? @relation("BracketTeam2", fields: [team2Id], references: [id])
|
||||||
@@ -174,7 +174,7 @@ model Match {
|
|||||||
bracketMatchups BracketMatchup[]
|
bracketMatchups BracketMatchup[]
|
||||||
eloSnapshots EloSnapshot[]
|
eloSnapshots EloSnapshot[]
|
||||||
createdBy User? @relation("MatchCreator", fields: [createdById], references: [id])
|
createdBy User? @relation("MatchCreator", fields: [createdById], references: [id])
|
||||||
event Event? @relation(fields: [eventId], references: [id])
|
event Event? @relation(fields: [eventId], references: [id], onDelete: Cascade)
|
||||||
team1P1 Player @relation("MatchPlayer1", fields: [team1P1Id], references: [id])
|
team1P1 Player @relation("MatchPlayer1", fields: [team1P1Id], references: [id])
|
||||||
team1P2 Player @relation("MatchPlayer2", fields: [team1P2Id], references: [id])
|
team1P2 Player @relation("MatchPlayer2", fields: [team1P2Id], references: [id])
|
||||||
team2P1 Player @relation("MatchPlayer3", fields: [team2P1Id], references: [id])
|
team2P1 Player @relation("MatchPlayer3", fields: [team2P1Id], references: [id])
|
||||||
@@ -192,7 +192,7 @@ model EloSnapshot {
|
|||||||
ratingAfter Int
|
ratingAfter Int
|
||||||
ratingChange Int
|
ratingChange Int
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
match Match @relation(fields: [matchId], references: [id])
|
match Match @relation(fields: [matchId], references: [id], onDelete: Cascade)
|
||||||
player Player @relation(fields: [playerId], references: [id])
|
player Player @relation(fields: [playerId], references: [id])
|
||||||
|
|
||||||
@@map("elo_snapshots")
|
@@map("elo_snapshots")
|
||||||
@@ -208,7 +208,7 @@ model PartnershipGame {
|
|||||||
player1EloChange Int?
|
player1EloChange Int?
|
||||||
player2EloChange Int?
|
player2EloChange Int?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
match Match @relation(fields: [matchId], references: [id])
|
match Match @relation(fields: [matchId], references: [id], onDelete: Cascade)
|
||||||
player1 Player @relation("PartnershipPlayer1", fields: [player1Id], references: [id])
|
player1 Player @relation("PartnershipPlayer1", fields: [player1Id], references: [id])
|
||||||
player2 Player @relation("PartnershipPlayer2", fields: [player2Id], references: [id])
|
player2 Player @relation("PartnershipPlayer2", fields: [player2Id], references: [id])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user