mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 15:17:43 -05:00
prisma schema implicit relation with roster
This commit is contained in:
@@ -26,16 +26,19 @@ CREATE TABLE "SalmonRunRecord" (
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "SalmonRunPlayer" (
|
||||
"recordId" INTEGER NOT NULL,
|
||||
"userId" INTEGER NOT NULL
|
||||
CREATE TABLE "_SalmonRunRecordRoster" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "SalmonRunRotation.id_unique" ON "SalmonRunRotation"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "SalmonRunPlayer.recordId_userId_unique" ON "SalmonRunPlayer"("recordId", "userId");
|
||||
CREATE UNIQUE INDEX "_SalmonRunRecordRoster_AB_unique" ON "_SalmonRunRecordRoster"("A", "B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_SalmonRunRecordRoster_B_index" ON "_SalmonRunRecordRoster"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SalmonRunRecord" ADD FOREIGN KEY("rotationId")REFERENCES "SalmonRunRotation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -44,7 +47,7 @@ ALTER TABLE "SalmonRunRecord" ADD FOREIGN KEY("rotationId")REFERENCES "SalmonRun
|
||||
ALTER TABLE "SalmonRunRecord" ADD FOREIGN KEY("submitterId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SalmonRunPlayer" ADD FOREIGN KEY("recordId")REFERENCES "SalmonRunRecord"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "_SalmonRunRecordRoster" ADD FOREIGN KEY("A")REFERENCES "SalmonRunRecord"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SalmonRunPlayer" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "_SalmonRunRecordRoster" ADD FOREIGN KEY("B")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -18,7 +18,7 @@ model User {
|
||||
player Player?
|
||||
builds Build[]
|
||||
submittedRecords SalmonRunRecord[]
|
||||
salmonRunRecords SalmonRunPlayer[]
|
||||
salmonRunRecords SalmonRunRecord[] @relation("SalmonRunRecordRoster")
|
||||
}
|
||||
|
||||
model Profile {
|
||||
@@ -203,14 +203,5 @@ model SalmonRunRecord {
|
||||
createdAt DateTime @default(now())
|
||||
rotation SalmonRunRotation @relation(fields: [rotationId], references: [id])
|
||||
submitter User @relation(fields: [submitterId], references: [id])
|
||||
players SalmonRunPlayer[]
|
||||
}
|
||||
|
||||
model SalmonRunPlayer {
|
||||
recordId Int
|
||||
userId Int
|
||||
record SalmonRunRecord @relation(fields: [recordId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
|
||||
@@unique([recordId, userId])
|
||||
roster User[] @relation("SalmonRunRecordRoster")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user