From 329e77f2743040dd2539b6cbefd66572a3be5a44 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sat, 13 Apr 2024 16:15:00 +0100 Subject: [PATCH] setting up models for non-intrusive survey notes and added isOverride boolean to recommendations table --- src/app/db/schema/property.ts | 19 +++++++++++++++++++ src/app/db/schema/recommendations.ts | 1 + 2 files changed, 20 insertions(+) diff --git a/src/app/db/schema/property.ts b/src/app/db/schema/property.ts index aea89a5..b9de840 100644 --- a/src/app/db/schema/property.ts +++ b/src/app/db/schema/property.ts @@ -204,6 +204,25 @@ export const propertyTargets = pgTable("property_targets", { heatDemand: text("heat_demand"), }); +// This is the model for the results of non-invasive surveys, associated with a property. +// We store the data against a uprn. Each row will contain a metadata about the survey itself +export const NonInstrusiveSurvey = pgTable("non_intrusive_survey", { + id: bigserial("id", { mode: "bigint" }).primaryKey(), + uprn: bigint("uprn", { mode: "bigint" }), + surveyDate: timestamp("survey_date"), + surveyor: text("surveyor"), +}); + +// This model contains the actual notes that were taken down during the non-invasive survey +export const NonIntrusiveSurveyNotes = pgTable("non_intrusive_survey_notes", { + id: bigserial("id", { mode: "bigint" }).primaryKey(), + surveyId: bigint("survey_id", { mode: "bigint" }) + .notNull() + .references(() => NonInstrusiveSurvey.id), + title: text("title"), + note: text("note"), +}); + export type Property = InferModel; export type PropertyDetailsEpc = InferModel< typeof propertyDetailsEpc, diff --git a/src/app/db/schema/recommendations.ts b/src/app/db/schema/recommendations.ts index ef48b09..855715b 100644 --- a/src/app/db/schema/recommendations.ts +++ b/src/app/db/schema/recommendations.ts @@ -37,6 +37,7 @@ export const recommendation = pgTable("recommendation", { rentalYieldIncrease: real("rental_yield_increase"), totalWorkHours: real("total_work_hours"), labourDays: real("labour_days"), + isOverride: boolean("is_override").default(false), }); export const unitQuantity: [string, ...string[]] = ["m2", "part"];