From e12c12d3375602691a8742a1526b9828b827bc8d Mon Sep 17 00:00:00 2001 From: Nicholas Chiang Date: Mon, 24 Jul 2023 22:30:54 -0600 Subject: [PATCH] fix: allow show date to be `NULL` when not known This patch updates the show model to make the `date` field optional so that I can simply let it be `NULL` when it is not conclusively known. --- app/routes/shows.$showId/show-info.tsx | 12 +++++++----- .../migration.sql | 2 ++ prisma/schema.prisma | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 prisma/migrations/20230725043026_make_show_date_optional/migration.sql diff --git a/app/routes/shows.$showId/show-info.tsx b/app/routes/shows.$showId/show-info.tsx index 52f58e4c..65ac6305 100644 --- a/app/routes/shows.$showId/show-info.tsx +++ b/app/routes/shows.$showId/show-info.tsx @@ -17,11 +17,13 @@ export function ShowInfo() { dangerouslySetInnerHTML={{ __html: show.description }} />
- - {new Date(show.date).toLocaleDateString(undefined, { - dateStyle: 'long', - })} - + {show.date != null && ( + + {new Date(show.date).toLocaleDateString(undefined, { + dateStyle: 'long', + })} + + )} {show.location != null && ( {show.location} )} diff --git a/prisma/migrations/20230725043026_make_show_date_optional/migration.sql b/prisma/migrations/20230725043026_make_show_date_optional/migration.sql new file mode 100644 index 00000000..343c596a --- /dev/null +++ b/prisma/migrations/20230725043026_make_show_date_optional/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Show" ALTER COLUMN "date" DROP NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0e9649e7..01fc62ee 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -855,8 +855,8 @@ model Show { season Season @relation(fields: [seasonId], references: [id], onDelete: Cascade, onUpdate: Cascade) seasonId Int - // The date when the show started. - date DateTime + // The date when the show started (if known). + date DateTime? // The runway show's location. // @todo perhaps this should be a separate model and simply a relation here.