From 4e67bcdce46ce2890eba8ad91f82e3008e0b4232 Mon Sep 17 00:00:00 2001 From: Nicholas Chiang Date: Mon, 24 Jul 2023 22:07:18 -0600 Subject: [PATCH] fix(prisma): mark most brand fields as optional 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. --- .../migration.sql | 5 +++++ prisma/schema.prisma | 18 +++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 prisma/migrations/20230725040705_make_most_brand_fields_optional/migration.sql diff --git a/prisma/migrations/20230725040705_make_most_brand_fields_optional/migration.sql b/prisma/migrations/20230725040705_make_most_brand_fields_optional/migration.sql new file mode 100644 index 00000000..0471b096 --- /dev/null +++ b/prisma/migrations/20230725040705_make_most_brand_fields_optional/migration.sql @@ -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; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7896a307..0e9649e7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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[] @@ -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.