Skip to content

Commit

Permalink
fix(prisma): mark most brand fields as optional
Browse files Browse the repository at this point in the history
This patch makes most of the brand fields optional. It is better that
these are left as NULL when importing brands than for me to set them to
something nonsensical. I will gradually populate these fields as
necessary, but their initial absence shouldn't block record creation.
  • Loading branch information
nicholaschiang committed Jul 25, 2023
1 parent 13e359f commit 4e67bcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Brand" ALTER COLUMN "description" DROP NOT NULL,
ALTER COLUMN "companyId" DROP NOT NULL,
ALTER COLUMN "countryId" DROP NOT NULL,
ALTER COLUMN "tier" DROP NOT NULL;
18 changes: 9 additions & 9 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ model Brand {
url String? @unique
// A short description of the brand, typically sourced from Wikipedia.
description String
description String?
// The brand's tier.
// The brand's tier. This will be NULL if it has not been assigned yet.
// @todo perhaps rename this to "BrandTier" to avoid confusion with "Level"?
tier Tier
tier Tier?
// The company that owns and operates the brand.
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade, onUpdate: Cascade)
companyId Int
// The company that owns and operates the brand (if known).
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade, onUpdate: Cascade)
companyId Int?
// The products designed or otherwise produced by the brand.
products Product[]
Expand All @@ -218,9 +218,9 @@ model Brand {
// The collections designed by the brand.
collections Collection[]
// The country the brand purports to be from.
country Country @relation(fields: [countryId], references: [id], onDelete: Cascade, onUpdate: Cascade)
countryId Int
// The country the brand purports to be from (if known).
country Country? @relation(fields: [countryId], references: [id], onDelete: Cascade, onUpdate: Cascade)
countryId Int?
}

// A country is a sovereign state. Countries can have many brands and sizes.
Expand Down

0 comments on commit 4e67bcd

Please sign in to comment.