From 427e0602a11d265da71254346eeefa482ab5066c Mon Sep 17 00:00:00 2001 From: zzhhaa Date: Fri, 13 Dec 2024 13:28:52 +0000 Subject: [PATCH 1/2] feat: make itl_lookup fields required --- .../migration.sql | 5 +++++ prisma/schema.prisma | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20241213132621_make_itl_lookup_field_required/migration.sql diff --git a/prisma/migrations/20241213132621_make_itl_lookup_field_required/migration.sql b/prisma/migrations/20241213132621_make_itl_lookup_field_required/migration.sql new file mode 100644 index 00000000..ed644676 --- /dev/null +++ b/prisma/migrations/20241213132621_make_itl_lookup_field_required/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "itl_lookup" ALTER COLUMN "postcode" SET NOT NULL, +ALTER COLUMN "district" SET NOT NULL, +ALTER COLUMN "areacode" SET NOT NULL, +ALTER COLUMN "itl3" SET NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 86e4c558..f67e8718 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -39,10 +39,10 @@ model HPI { } model ItlLookup { - postcode String? - district String? - areacode String? - itl3 String? + postcode String + district String + areacode String + itl3 String id Int @id @default(autoincrement()) @@map("itl_lookup") From 230b21bf99cbae63cb7dbfcae94f3fd4d4cf0939 Mon Sep 17 00:00:00 2001 From: zzhhaa Date: Fri, 13 Dec 2024 14:05:25 +0000 Subject: [PATCH 2/2] feat: remove not null guard in itlRepo since already required in schema --- app/data/itlRepo.test.ts | 3 --- app/data/itlRepo.ts | 3 --- 2 files changed, 6 deletions(-) diff --git a/app/data/itlRepo.test.ts b/app/data/itlRepo.test.ts index 1b7ba1fe..21031a4e 100644 --- a/app/data/itlRepo.test.ts +++ b/app/data/itlRepo.test.ts @@ -27,9 +27,6 @@ describe("itlRepo", () => { expect(prisma.itlLookup.findFirstOrThrow).toHaveBeenCalledWith({ where: { postcode: postcodeDistrict, - itl3: { - not: null, - }, }, select: { itl3: true, diff --git a/app/data/itlRepo.ts b/app/data/itlRepo.ts index 656734a0..fadb0ba7 100644 --- a/app/data/itlRepo.ts +++ b/app/data/itlRepo.ts @@ -7,9 +7,6 @@ const getItl3ByPostcodeDistrict = async ( const { itl3 } = await prisma.itlLookup.findFirstOrThrow({ where: { postcode: postcodeDistrict, - itl3: { - not: null, - }, }, select: { itl3: true,