mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
Merge pull request #321 from Hestia-Homes/feature/epc-prediction-source-column
feat(db): add epc_property.source for predicted-EPC slot (ADR-0031)
This commit is contained in:
commit
e606006e6b
4 changed files with 10992 additions and 0 deletions
4
src/app/db/migrations/0234_old_rachel_grey.sql
Normal file
4
src/app/db/migrations/0234_old_rachel_grey.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
DROP INDEX "uq_epc_property_property_portfolio";--> statement-breakpoint
|
||||
ALTER TABLE "epc_property" ADD COLUMN "source" text DEFAULT 'lodged' NOT NULL;--> statement-breakpoint
|
||||
CREATE INDEX "ix_epc_property_property_source" ON "epc_property" USING btree ("property_id","source");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "uq_epc_property_property_portfolio" ON "epc_property" USING btree ("property_id","portfolio_id","source");
|
||||
10966
src/app/db/migrations/meta/0234_snapshot.json
Normal file
10966
src/app/db/migrations/meta/0234_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1632,6 +1632,13 @@
|
|||
"when": 1781513971818,
|
||||
"tag": "0233_abnormal_george_stacy",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 234,
|
||||
"version": "7",
|
||||
"when": 1781617412914,
|
||||
"tag": "0234_old_rachel_grey",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import {
|
|||
smallint,
|
||||
bigint,
|
||||
uniqueIndex,
|
||||
index,
|
||||
jsonb,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { portfolio, PortfolioStatus } from "./portfolio";
|
||||
|
|
@ -428,6 +429,12 @@ export const epcProperty = pgTable(
|
|||
.unique()
|
||||
.references(() => uploadedFiles.id),
|
||||
|
||||
// Provenance of this EPC picture: "lodged" (a real public/landlord EPC) or
|
||||
// "predicted" (EPC Prediction gap-fill, ADR-0031 in the Model repo). A
|
||||
// property may hold one of each, so reads filter on it. Defaults to "lodged"
|
||||
// — every existing row is a real lodged EPC.
|
||||
source: text("source").notNull().default("lodged"),
|
||||
|
||||
// Identity / admin
|
||||
uprn: bigint("uprn", { mode: "bigint" }),
|
||||
uprnSource: text("uprn_source"),
|
||||
|
|
@ -577,9 +584,17 @@ export const epcProperty = pgTable(
|
|||
ventilationMechanicalVentilationKind: text("ventilation_mechanical_ventilation_kind"),
|
||||
},
|
||||
(table) => [
|
||||
// A property may now hold one "lodged" and one "predicted" EPC row per
|
||||
// portfolio (ADR-0031), so `source` is part of the uniqueness key.
|
||||
uniqueIndex("uq_epc_property_property_portfolio").on(
|
||||
table.propertyId,
|
||||
table.portfolioId,
|
||||
table.source,
|
||||
),
|
||||
// Every lodged/predicted read filters on (property_id, source).
|
||||
index("ix_epc_property_property_source").on(
|
||||
table.propertyId,
|
||||
table.source,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue