Skip to content

Commit

Permalink
cascade delete all step types (#1167)
Browse files Browse the repository at this point in the history
update schema and migrate
  • Loading branch information
stormcloud266 authored Mar 21, 2024
1 parent 97443a8 commit 950bf62
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-- DropForeignKey
ALTER TABLE "NftCheckDatum" DROP CONSTRAINT "NftCheckDatum_stepNftCheckId_fkey";

-- DropForeignKey
ALTER TABLE "StepAssetTransfer" DROP CONSTRAINT "StepAssetTransfer_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepComethApi" DROP CONSTRAINT "StepComethApi_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepErc20Balance" DROP CONSTRAINT "StepErc20Balance_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepFunctionCall" DROP CONSTRAINT "StepFunctionCall_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepLensApi" DROP CONSTRAINT "StepLensApi_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepNftCheck" DROP CONSTRAINT "StepNftCheck_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepOriumApi" DROP CONSTRAINT "StepOriumApi_stepId_fkey";

-- DropForeignKey
ALTER TABLE "StepTokenIdRange" DROP CONSTRAINT "StepTokenIdRange_stepId_fkey";

-- AddForeignKey
ALTER TABLE "StepFunctionCall" ADD CONSTRAINT "StepFunctionCall_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "NftCheckDatum" ADD CONSTRAINT "NftCheckDatum_stepNftCheckId_fkey" FOREIGN KEY ("stepNftCheckId") REFERENCES "StepNftCheck"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepNftCheck" ADD CONSTRAINT "StepNftCheck_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepComethApi" ADD CONSTRAINT "StepComethApi_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepErc20Balance" ADD CONSTRAINT "StepErc20Balance_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepOriumApi" ADD CONSTRAINT "StepOriumApi_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepTokenIdRange" ADD CONSTRAINT "StepTokenIdRange_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepLensApi" ADD CONSTRAINT "StepLensApi_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StepAssetTransfer" ADD CONSTRAINT "StepAssetTransfer_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;
18 changes: 9 additions & 9 deletions api/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ model StepSimpleText {
model StepFunctionCall {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
/// MethodIds for the functions we want to check
Expand All @@ -288,15 +288,15 @@ model NftCheckDatum {
chainId Int?
poapEventId String?
StepNftCheck StepNftCheck? @relation(fields: [stepNftCheckId], references: [id])
StepNftCheck StepNftCheck? @relation(fields: [stepNftCheckId], references: [id], onDelete: Cascade)
stepNftCheckId String?
}

/// Require the user to have one or many NFTs or POAPs for a step
model StepNftCheck {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
nftCheckData NftCheckDatum[]
Expand All @@ -308,15 +308,15 @@ model StepNftCheck {
model StepComethApi {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
}

/// Require the user have a minimum erc20 balance
model StepErc20Balance {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
/// The token's contract address
Expand All @@ -338,7 +338,7 @@ enum OriumCheckType {
model StepOriumApi {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
/// We can check the Orium API for different passing states
Expand All @@ -349,7 +349,7 @@ model StepOriumApi {
model StepTokenIdRange {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
contractAddress String
Expand All @@ -371,7 +371,7 @@ enum LensCheckType {
model StepLensApi {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
/// Choose the type of Lens API call you would like to check
Expand All @@ -384,7 +384,7 @@ model StepLensApi {
model StepAssetTransfer {
id String @id @default(cuid())
step Step @relation(fields: [stepId], references: [id])
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
stepId String @unique
toAddress String
Expand Down

0 comments on commit 950bf62

Please sign in to comment.