From f2d2e947de9951a522a8366a91fc95fe89aa54fc Mon Sep 17 00:00:00 2001 From: Joe Karow <58997957+JoeKarow@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:13:34 -0500 Subject: [PATCH] update bool defaults --- .../migration.sql | 37 +++++++++++++++++++ packages/db/prisma/schema.prisma | 6 +-- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 packages/db/prisma/migrations/20231211210937_boolean_defaults_for_location/migration.sql diff --git a/packages/db/prisma/migrations/20231211210937_boolean_defaults_for_location/migration.sql b/packages/db/prisma/migrations/20231211210937_boolean_defaults_for_location/migration.sql new file mode 100644 index 0000000000..ab2af21f3e --- /dev/null +++ b/packages/db/prisma/migrations/20231211210937_boolean_defaults_for_location/migration.sql @@ -0,0 +1,37 @@ +/* + Warnings: + + - Made the column `mailOnly` on table `OrgLocation` required. This step will fail if there are existing NULL values in that column. + - Made the column `mapCityOnly` on table `OrgLocation` required. This step will fail if there are existing NULL values in that column. + - Made the column `notVisitable` on table `OrgLocation` required. This step will fail if there are existing NULL values in that column. + */ +-- Update values for Location +UPDATE + "OrgLocation" +SET + "mailOnly" = FALSE +WHERE + "mailOnly" IS NULL; + +UPDATE + "OrgLocation" +SET + "mapCityOnly" = FALSE +WHERE + "mapCityOnly" IS NULL; + +UPDATE + "OrgLocation" +SET + "notVisitable" = FALSE +WHERE + "notVisitable" IS NULL; + +-- AlterTable +ALTER TABLE "OrgLocation" + ALTER COLUMN "mailOnly" SET NOT NULL, + ALTER COLUMN "mailOnly" SET DEFAULT FALSE, + ALTER COLUMN "mapCityOnly" SET NOT NULL, + ALTER COLUMN "mapCityOnly" SET DEFAULT FALSE, + ALTER COLUMN "notVisitable" SET NOT NULL, + ALTER COLUMN "notVisitable" SET DEFAULT FALSE; diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma index f17d3bf837..5fc329e11f 100644 --- a/packages/db/prisma/schema.prisma +++ b/packages/db/prisma/schema.prisma @@ -631,9 +631,9 @@ model OrgLocation { postCode String? primary Boolean @default(false) - mailOnly Boolean? - notVisitable Boolean? - mapCityOnly Boolean? + mailOnly Boolean @default(false) + notVisitable Boolean @default(false) + mapCityOnly Boolean @default(false) description FreeText? @relation(fields: [descriptionId], references: [id], onDelete: SetNull, onUpdate: Cascade) descriptionId String? @unique