From a32a6fbcb8cf04e7b23ffa72e8c516a7df369a9e Mon Sep 17 00:00:00 2001 From: franz Date: Thu, 21 Nov 2024 16:37:33 +0100 Subject: [PATCH] add migration and adapt filter --- modules/pool/lib/pool-gql-loader.service.ts | 2 +- modules/pool/pool-debug.test.ts | 7 +++++- .../migration.sql | 23 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 prisma/migrations/20241121152607_integrate_hook_to_pool/migration.sql diff --git a/modules/pool/lib/pool-gql-loader.service.ts b/modules/pool/lib/pool-gql-loader.service.ts index eb35e620..09da4938 100644 --- a/modules/pool/lib/pool-gql-loader.service.ts +++ b/modules/pool/lib/pool-gql-loader.service.ts @@ -576,7 +576,7 @@ export class PoolGqlLoaderService { ...(where?.hasHook !== undefined && where.hasHook ? { hook: { not: {} } } : where?.hasHook !== undefined && !where.hasHook - ? { hook: { equals: {} } } + ? { hook: { equals: Prisma.DbNull } } : {}), }; diff --git a/modules/pool/pool-debug.test.ts b/modules/pool/pool-debug.test.ts index 37ea5522..777cb257 100644 --- a/modules/pool/pool-debug.test.ts +++ b/modules/pool/pool-debug.test.ts @@ -10,6 +10,7 @@ import { ContentController } from '../controllers/content-controller'; import { chainToIdMap } from '../network/network-config'; import { PoolController } from '../controllers'; import { GqlPoolComposableStable, GqlPoolStable } from '../../schema'; +import { Prisma } from '@prisma/client'; describe('pool debugging', () => { it('query pools', async () => { initRequestScopedContext(); @@ -372,7 +373,11 @@ describe('pool debugging', () => { }); const poolsWithoutHooks = await prisma.prismaPool.findMany({ - where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { equals: {} } }, + where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { equals: Prisma.AnyNull } }, + }); + + const poolsWithHooks = await prisma.prismaPool.findMany({ + where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { not: {} } }, }); console.log(gqlPoolsWithHooks.length); diff --git a/prisma/migrations/20241121152607_integrate_hook_to_pool/migration.sql b/prisma/migrations/20241121152607_integrate_hook_to_pool/migration.sql new file mode 100644 index 00000000..bcf35ca9 --- /dev/null +++ b/prisma/migrations/20241121152607_integrate_hook_to_pool/migration.sql @@ -0,0 +1,23 @@ +/* + Warnings: + + - You are about to drop the column `hookId` on the `PrismaPool` table. All the data in the column will be lost. + - You are about to drop the `PrismaHook` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `PrismaHookReviewData` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "PrismaHookReviewData" DROP CONSTRAINT "PrismaHookReviewData_chain_hookAddress_fkey"; + +-- DropForeignKey +ALTER TABLE "PrismaPool" DROP CONSTRAINT "PrismaPool_hookId_fkey"; + +-- AlterTable +ALTER TABLE "PrismaPool" DROP COLUMN "hookId", +ADD COLUMN "hook" JSONB; + +-- DropTable +DROP TABLE "PrismaHook"; + +-- DropTable +DROP TABLE "PrismaHookReviewData";