Skip to content

Commit

Permalink
feat: Rename gdhi, add not null constraints (#163)
Browse files Browse the repository at this point in the history
* feat: Rename gdhi tables, add not null constraints

* test: Update test case
  • Loading branch information
DafyddLlyr authored Dec 13, 2024
1 parent 6312e95 commit 6321c94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/data/gdhiRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe("gdhiRepo", () => {
where: {
AND: {
itl3: { equals: itl3 },
gdhi2020: { not: null },
},
},
select: { gdhi2020: true },
Expand Down
4 changes: 1 addition & 3 deletions app/data/gdhiRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ const getGDHI2020ByITL3 = async (itl3: string): Promise<number> => {
where: {
AND: {
itl3: { equals: itl3 },
// TODO: Add `NOT NULL` constraint to column
gdhi2020: { not: null },
},
},
select: { gdhi2020: true },
});

return gdhi2020 as number;
return gdhi2020;
} catch (error) {
throw Error(`Data error: Unable to find gdhi2020 for itl3 ${itl3}`);
}
Expand Down
10 changes: 10 additions & 0 deletions prisma/migrations/20241206162843_rename_ghdi_table/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- AlterTable
ALTER TABLE "gdhi"
RENAME COLUMN "itllevel" TO "itl_level";

-- AlterTable
ALTER TABLE "gdhi"
ALTER COLUMN "itl_level" SET NOT NULL,
ALTER COLUMN "itl3" SET NOT NULL,
ALTER COLUMN "region" SET NOT NULL,
ALTER COLUMN "gdhi_2020" SET NOT NULL;
8 changes: 4 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ model BuildPrices {

model GDHI {
id Int @id @default(autoincrement())
itlLevel String? @map("itllevel") @db.VarChar(250)
itl3 String? @db.VarChar(250)
region String? @db.VarChar(250)
gdhi2020 Float? @map("gdhi_2020")
itlLevel String @map("itl_level") @db.VarChar(250)
itl3 String @db.VarChar(250)
region String @db.VarChar(250)
gdhi2020 Float @map("gdhi_2020")
@@map("gdhi")
}
Expand Down

0 comments on commit 6321c94

Please sign in to comment.