Skip to content

Commit

Permalink
feat: Rename gdhi tables, add not null constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 6, 2024
1 parent 30841ab commit 1c6ca4b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
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 1c6ca4b

Please sign in to comment.