Skip to content

Commit

Permalink
update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
stormcloud266 committed Mar 20, 2024
1 parent 05e8637 commit 78565ce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- DropForeignKey
ALTER TABLE "Puzzle" DROP CONSTRAINT "Puzzle_rewardableId_fkey";

-- DropForeignKey
ALTER TABLE "RewardableConnection" DROP CONSTRAINT "RewardableConnection_childId_fkey";

-- DropForeignKey
ALTER TABLE "RewardableConnection" DROP CONSTRAINT "RewardableConnection_parentId_fkey";

-- DropForeignKey
ALTER TABLE "Step" DROP CONSTRAINT "Step_puzzleId_fkey";

-- DropForeignKey
ALTER TABLE "Submission" DROP CONSTRAINT "Submission_puzzleId_fkey";

-- DropForeignKey
ALTER TABLE "UserReward" DROP CONSTRAINT "UserReward_rewardableId_fkey";

-- AddForeignKey
ALTER TABLE "UserReward" ADD CONSTRAINT "UserReward_rewardableId_fkey" FOREIGN KEY ("rewardableId") REFERENCES "Rewardable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "RewardableConnection" ADD CONSTRAINT "RewardableConnection_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Rewardable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "RewardableConnection" ADD CONSTRAINT "RewardableConnection_childId_fkey" FOREIGN KEY ("childId") REFERENCES "Rewardable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Puzzle" ADD CONSTRAINT "Puzzle_rewardableId_fkey" FOREIGN KEY ("rewardableId") REFERENCES "Rewardable"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Step" ADD CONSTRAINT "Step_puzzleId_fkey" FOREIGN KEY ("puzzleId") REFERENCES "Puzzle"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Submission" ADD CONSTRAINT "Submission_puzzleId_fkey" FOREIGN KEY ("puzzleId") REFERENCES "Puzzle"("rewardableId") ON DELETE CASCADE ON UPDATE CASCADE;
12 changes: 6 additions & 6 deletions api/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ model UserReward {
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId String
rewardable Rewardable @relation(fields: [rewardableId], references: [id])
rewardable Rewardable @relation(fields: [rewardableId], references: [id], onDelete: Cascade)
rewardableId String
nfts Nft[]
Expand All @@ -88,9 +88,9 @@ model UserReward {
model RewardableConnection {
id String @id @default(cuid())
parentRewardable Rewardable @relation("ParentLink", fields: [parentId], references: [id])
parentRewardable Rewardable @relation("ParentLink", fields: [parentId], references: [id], onDelete: Cascade)
parentId String
childRewardable Rewardable @relation("ChildLink", fields: [childId], references: [id])
childRewardable Rewardable @relation("ChildLink", fields: [childId], references: [id], onDelete: Cascade)
childId String
childSortWeight Int? @default(1)
Expand Down Expand Up @@ -123,7 +123,7 @@ model Bundle {
model Puzzle {
id String @id @default(cuid())
rewardable Rewardable @relation(fields: [rewardableId], references: [id])
rewardable Rewardable @relation(fields: [rewardableId], references: [id], onDelete: Cascade)
rewardableId String @unique
// Users can fill out a form and submit answers when completing a puzzle
Expand Down Expand Up @@ -189,7 +189,7 @@ model Step {
stepSortWeight Int @default(1)
// Connect this step to exactly 1 Puzzle
puzzle Puzzle @relation(fields: [puzzleId], references: [id])
puzzle Puzzle @relation(fields: [puzzleId], references: [id], onDelete: Cascade)
puzzleId String
// Step types
Expand Down Expand Up @@ -398,7 +398,7 @@ model Submission {
data Json
puzzle Puzzle @relation(fields: [puzzleId], references: [rewardableId])
puzzle Puzzle @relation(fields: [puzzleId], references: [rewardableId], onDelete: Cascade)
puzzleId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId String
Expand Down

0 comments on commit 78565ce

Please sign in to comment.