Ajout comportements en cas de suppresion d'un élément lié
This commit is contained in:
parent
601b337369
commit
8878a13f4f
@ -0,0 +1,41 @@
|
|||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "ChallengeAction" DROP CONSTRAINT "ChallengeAction_challengeId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "Geolocation" DROP CONSTRAINT "Geolocation_playerId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "MoneyUpdate" DROP CONSTRAINT "MoneyUpdate_actionId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "MoneyUpdate" DROP CONSTRAINT "MoneyUpdate_runId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "MoneyUpdate" DROP CONSTRAINT "MoneyUpdate_tripId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "PlayerRun" DROP CONSTRAINT "PlayerRun_gameId_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "PlayerRun" DROP CONSTRAINT "PlayerRun_runnerId_fkey";
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PlayerRun" ADD CONSTRAINT "PlayerRun_gameId_fkey" FOREIGN KEY ("gameId") REFERENCES "Game"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PlayerRun" ADD CONSTRAINT "PlayerRun_runnerId_fkey" FOREIGN KEY ("runnerId") REFERENCES "Player"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Geolocation" ADD CONSTRAINT "Geolocation_playerId_fkey" FOREIGN KEY ("playerId") REFERENCES "Player"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ChallengeAction" ADD CONSTRAINT "ChallengeAction_challengeId_fkey" FOREIGN KEY ("challengeId") REFERENCES "Challenge"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "MoneyUpdate" ADD CONSTRAINT "MoneyUpdate_actionId_fkey" FOREIGN KEY ("actionId") REFERENCES "ChallengeAction"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "MoneyUpdate" ADD CONSTRAINT "MoneyUpdate_tripId_fkey" FOREIGN KEY ("tripId") REFERENCES "TrainTrip"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "MoneyUpdate" ADD CONSTRAINT "MoneyUpdate_runId_fkey" FOREIGN KEY ("runId") REFERENCES "PlayerRun"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
@ -12,7 +12,7 @@ model Player {
|
|||||||
name String @unique
|
name String @unique
|
||||||
password String
|
password String
|
||||||
money Int @default(0)
|
money Int @default(0)
|
||||||
activeChallenge ChallengeAction? @relation("ActiveChallenge", fields: [activeChallengeId], references: [id])
|
activeChallenge ChallengeAction? @relation("ActiveChallenge", fields: [activeChallengeId], references: [id], onDelete: SetNull)
|
||||||
activeChallengeId Int? @unique
|
activeChallengeId Int? @unique
|
||||||
actions ChallengeAction[]
|
actions ChallengeAction[]
|
||||||
geolocations Geolocation[]
|
geolocations Geolocation[]
|
||||||
@ -24,17 +24,17 @@ model Player {
|
|||||||
model Game {
|
model Game {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
started Boolean @default(false)
|
started Boolean @default(false)
|
||||||
currentRun PlayerRun? @relation("CurrentRun", fields: [currentRunId], references: [id])
|
currentRun PlayerRun? @relation("CurrentRun", fields: [currentRunId], references: [id], onDelete: SetNull)
|
||||||
currentRunId Int? @unique
|
currentRunId Int? @unique
|
||||||
runs PlayerRun[] @relation("GameRuns")
|
runs PlayerRun[] @relation("GameRuns")
|
||||||
}
|
}
|
||||||
|
|
||||||
model PlayerRun {
|
model PlayerRun {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
game Game @relation("GameRuns", fields: [gameId], references: [id])
|
game Game @relation("GameRuns", fields: [gameId], references: [id], onDelete: Cascade)
|
||||||
runningGame Game? @relation("CurrentRun")
|
runningGame Game? @relation("CurrentRun")
|
||||||
gameId Int
|
gameId Int
|
||||||
runner Player @relation(fields: [runnerId], references: [id])
|
runner Player @relation(fields: [runnerId], references: [id], onDelete: Cascade)
|
||||||
runnerId Int
|
runnerId Int
|
||||||
start DateTime @default(now()) @db.Timestamptz(3)
|
start DateTime @default(now()) @db.Timestamptz(3)
|
||||||
end DateTime? @db.Timestamptz(3)
|
end DateTime? @db.Timestamptz(3)
|
||||||
@ -45,7 +45,7 @@ model PlayerRun {
|
|||||||
|
|
||||||
model Geolocation {
|
model Geolocation {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
player Player @relation(fields: [playerId], references: [id])
|
player Player @relation(fields: [playerId], references: [id], onDelete: Cascade)
|
||||||
playerId Int
|
playerId Int
|
||||||
longitude Float
|
longitude Float
|
||||||
latitude Float
|
latitude Float
|
||||||
@ -66,16 +66,16 @@ model Challenge {
|
|||||||
|
|
||||||
model ChallengeAction {
|
model ChallengeAction {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
player Player @relation(fields: [playerId], references: [id])
|
player Player @relation(fields: [playerId], references: [id], onDelete: Restrict)
|
||||||
playerId Int
|
playerId Int
|
||||||
challenge Challenge @relation(fields: [challengeId], references: [id])
|
challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade)
|
||||||
challengeId Int @unique
|
challengeId Int @unique
|
||||||
success Boolean @default(false)
|
success Boolean @default(false)
|
||||||
start DateTime @default(now()) @db.Timestamptz(3)
|
start DateTime @default(now()) @db.Timestamptz(3)
|
||||||
end DateTime? @db.Timestamptz(3)
|
end DateTime? @db.Timestamptz(3)
|
||||||
penaltyStart DateTime? @db.Timestamptz(3)
|
penaltyStart DateTime? @db.Timestamptz(3)
|
||||||
penaltyEnd DateTime? @db.Timestamptz(3)
|
penaltyEnd DateTime? @db.Timestamptz(3)
|
||||||
run PlayerRun @relation(fields: [runId], references: [id])
|
run PlayerRun @relation(fields: [runId], references: [id], onDelete: Restrict)
|
||||||
runId Int
|
runId Int
|
||||||
activePlayer Player? @relation("ActiveChallenge")
|
activePlayer Player? @relation("ActiveChallenge")
|
||||||
moneyUpdate MoneyUpdate?
|
moneyUpdate MoneyUpdate?
|
||||||
@ -83,7 +83,7 @@ model ChallengeAction {
|
|||||||
|
|
||||||
model TrainTrip {
|
model TrainTrip {
|
||||||
id String @id
|
id String @id
|
||||||
player Player @relation(fields: [playerId], references: [id])
|
player Player @relation(fields: [playerId], references: [id], onDelete: Restrict)
|
||||||
playerId Int
|
playerId Int
|
||||||
distance Float
|
distance Float
|
||||||
from String
|
from String
|
||||||
@ -91,22 +91,22 @@ model TrainTrip {
|
|||||||
departureTime DateTime @db.Timestamptz(3)
|
departureTime DateTime @db.Timestamptz(3)
|
||||||
arrivalTime DateTime @db.Timestamptz(3)
|
arrivalTime DateTime @db.Timestamptz(3)
|
||||||
infoJson Json
|
infoJson Json
|
||||||
run PlayerRun @relation(fields: [runId], references: [id])
|
run PlayerRun @relation(fields: [runId], references: [id], onDelete: Restrict)
|
||||||
runId Int
|
runId Int
|
||||||
moneyUpdate MoneyUpdate?
|
moneyUpdate MoneyUpdate?
|
||||||
}
|
}
|
||||||
|
|
||||||
model MoneyUpdate {
|
model MoneyUpdate {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
player Player @relation(fields: [playerId], references: [id])
|
player Player @relation(fields: [playerId], references: [id], onDelete: Restrict)
|
||||||
playerId Int
|
playerId Int
|
||||||
amount Int
|
amount Int
|
||||||
reason MoneyUpdateType
|
reason MoneyUpdateType
|
||||||
action ChallengeAction? @relation(fields: [actionId], references: [id])
|
action ChallengeAction? @relation(fields: [actionId], references: [id], onDelete: Cascade)
|
||||||
actionId Int? @unique
|
actionId Int? @unique
|
||||||
trip TrainTrip? @relation(fields: [tripId], references: [id])
|
trip TrainTrip? @relation(fields: [tripId], references: [id], onDelete: Cascade)
|
||||||
tripId String? @unique
|
tripId String? @unique
|
||||||
run PlayerRun? @relation(fields: [runId], references: [id])
|
run PlayerRun? @relation(fields: [runId], references: [id], onDelete: Cascade)
|
||||||
runId Int? @unique
|
runId Int? @unique
|
||||||
timestamp DateTime @default(now()) @db.Timestamptz(3)
|
timestamp DateTime @default(now()) @db.Timestamptz(3)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user