diff --git a/.claude/settings.json b/.claude/settings.json
index e89494b4..490e7d82 100644
--- a/.claude/settings.json
+++ b/.claude/settings.json
@@ -21,7 +21,9 @@
"Bash(npx drizzle-kit *)",
"Bash(pip install *)",
"Bash(terraform fmt *)",
- "Bash(gh label *)"
+ "Bash(gh label *)",
+ "Bash(python3 -c \"import psycopg2\")",
+ "Bash(python3 -c \"import psycopg\")"
],
"deny": [
"Bash(npx drizzle-kit generate)",
diff --git a/.gitignore b/.gitignore
index 04f701b5..237fa406 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,3 +46,9 @@ docs/wip/**
# Personal Claude Code settings (per-developer, not shared)
.claude/settings.local.json
+
+# transient local scratch (dev session helpers)
+.mint.cjs
+.chip-preview.*
+.shot.cjs
+scratch-*.cjs
diff --git a/.impeccable/critique/2026-07-13T21-29-24Z__rc-app-portfolio-slug-components-propertytable-tsx.md b/.impeccable/critique/2026-07-13T21-29-24Z__rc-app-portfolio-slug-components-propertytable-tsx.md
new file mode 100644
index 00000000..73736a11
--- /dev/null
+++ b/.impeccable/critique/2026-07-13T21-29-24Z__rc-app-portfolio-slug-components-propertytable-tsx.md
@@ -0,0 +1,78 @@
+---
+target: portfolio page (property table + toolbar + no-plans state)
+total_score: 27
+p0_count: 1
+p1_count: 1
+timestamp: 2026-07-13T21-29-24Z
+slug: rc-app-portfolio-slug-components-propertytable-tsx
+---
+Method: dual-agent (A: ad10a436 design-review · B: a517f2c1 detector+evidence)
+
+## Design Health Score
+
+| # | Heuristic | Score | Key Issue |
+|---|-----------|-------|-----------|
+| 1 | Visibility of System Status | 3 | Good results count + spinner overlay, but first-load is bare "Loading properties…" (no skeleton) and a no-plans portfolio gives zero signal that modelling is the missing step. |
+| 2 | Match System / Real World | 3 | "Plan Cost / No cost", "Expected EPC" read well; but blank EPC bubbles + "—" Ref communicate nothing about *why* they're empty. |
+| 3 | User Control and Freedom | 3 | Clear/Clear-all on filters + selection; no undo on optimistic tag assign, no cancel-export. |
+| 4 | Consistency and Standards | 2 | Two colour systems: toolbar uses brandblue/primary; filter sidebar + Edit-Columns checkboxes use raw black/bg-black/accent-black. |
+| 5 | Error Prevention | 3 | Delete has a preview modal, export gated >6000 — but the delete modal has Cancel and no wired Confirm (dead-end). |
+| 6 | Recognition Rather Than Recall | 3 | Columns labelled, Current EPC has a "?" tooltip; but Current/Lodged/Expected are three identical blank bubbles with no legend when empty. |
+| 7 | Flexibility and Efficiency | 3 | Column visibility, quick filters, filter builder, export — strong; undercut by a 7-row page size on a desk tool. |
+| 8 | Aesthetic and Minimalist Design | 2 | The no-plans grid is a wall of "—", blank bubbles, italic "No cost"; 6 top-level toolbar actions + two dark CTAs + shouty micro-labels. |
+| 9 | Error Recovery | 3 | load-more + export fail silently; tag-assign error only shows inline in the popover footer. |
+| 10 | Help and Documentation | 2 | One tooltip (Current EPC); no inline guidance connecting an unmodelled portfolio to "Run modelling". |
+| **Total** | | **27/40** | **Acceptable — solid plumbing, dragged down by the empty state + consistency** |
+
+## Anti-Patterns Verdict
+
+**LLM assessment:** Not egregious slop — the table is competently built and restrained — but three tells betray a generated-template lineage: tiny uppercase black micro-labels everywhere (`RESULTS:` font-black uppercase, `CURATE SELECTION` at 9px), `rounded-xl` + `shadow-sm` cards the brief names as an anti-reference, and em-dash-as-content filling 5–6 of 9 columns. Bones are institutional; finish is generic-admin.
+
+**Deterministic scan:** detect.mjs exit 0 — **zero findings**. No gradient text, decorative gradients, side-stripe borders, glassmorphism, over-rounded radii (only rounded-lg/xl/full), heavy shadows (only shadow-sm), or arbitrary z-index. The mechanical slop tells are genuinely absent — the problems here are IA/hierarchy/contrast that a static scanner can't see, which is exactly where the design review earns its keep.
+
+**Visual overlays:** none — browser automation unavailable (arm64 container can't run the bundled x86 Chromium under qemu). Fallback: static grep evidence corroborated the review (8 placeholder "—" cells in propertyTableColumns.tsx: 256/336/442/451/459/470/483/494; text-slate-300 at 384/442/451/494/524; 6 toolbar controls at 602/617/658/686/693/742; no dedicated no-plans empty-state component).
+
+## Overall Impression
+
+The interaction plumbing is genuinely good (optimistic tag writes, filter-scoped selection, provenance signalling). What lets it down is a single unaddressed truth: **the default state of every brand-new portfolio — properties added, nothing modelled — is the one state with zero design investment.** A first-time housing-association user lands on 185 rows where Ref is "—", three EPC columns are blank, Expiry is "—", and every Plan Cost is a faint italic "No cost". The read isn't "fresh start", it's "this tool is broken / my import failed" — the worst possible first impression for a product whose promise is *trustworthy numbers*. The single biggest opportunity is to design the unmodelled state as a first-class surface, not a fallthrough.
+
+## What's Working
+
+1. **The Current-EPC "?" tooltip** — exactly right for the institutional register: explains a load-bearing figure inline without cluttering the header. A pattern to extend, not remove.
+2. **The Predicted pill + provenance model** (amber "Predicted", ADR-0002) — genuine trust-signalling that tells analysts which EPCs to trust less; precisely the "trustworthy numbers" value the brand claims.
+3. **Optimistic tag writes across every cached page + filter-scoped selection surviving pagination** — Linear/Stripe-class plumbing, invisible when it works.
+
+## Priority Issues
+
+**[P0] The no-plans / unmodelled state has no design at all.** `EmptyPropertyState` only fires when there are literally zero rows; a portfolio with 185 unmodelled properties falls straight through to the full table with 5–6 empty columns. This is the *default* state of every new portfolio and the exact case flagged as "terrible". **Fix:** detect "has properties, zero plans/EPC" and render a purpose-built view — collapse/hide the three EPC + Expiry + Plan Cost columns, show Address/Ref/Tags at full density, and surface one reassuring banner ("185 properties added — run modelling to generate EPC ratings and retrofit costs →") wired to the existing Run-modelling route. *Command: `onboard`*
+
+**[P1] Empty cells fail contrast and read as breakage.** `text-slate-300 italic` "No cost" and slate-300 em-dashes / "Unknown" are below WCAG AA on white and make populated data indistinguishable from missing data at a glance. Four different "empty" renderings coexist (blank `w-5 h-5` div, "—", italic "No cost", "Unknown"). **Fix:** raise empty text to slate-400/500 and pick ONE absence vocabulary. *Command: `harden`*
+
+**[P2] Six top-level toolbar actions with two competing dark CTAs.** Filters, Edit Columns, Export, Tags▾, Add properties▾, Run modelling in one undifferentiated row; Add properties and Run modelling are both navy `bg-primary` — no primary focus, and the brief says navy belongs "in small doses". **Fix:** one dark CTA at a time (Add properties when empty → Run modelling once populated), fold Export/Edit Columns/Tags into a quieter secondary group. *Command: `distill`*
+
+**[P3] Colour-system drift between toolbar and filter sidebar.** Toolbar uses brandblue/primary; `PropertyFilters.tsx` and the Edit-Columns checkboxes use raw black/bg-black/accent-black — two systems on one page. **Fix:** replace every black token with the brand navy/brandblue scale. *Command: `colorize`*
+
+**[P3] No first-load skeleton; silent failures.** First load is a lone "Loading properties…" string; load-more and export swallow errors (`// silently ignore`). For a data-trust product a silent export failure is a credibility risk. **Fix:** skeleton rows + a toast/inline error on export and load-more failure. *Command: `polish`*
+
+## Persona Red Flags
+
+**Alex (power user):** `pageSize: 7` on a large desk screen means paging 27× through 185 homes; lazy load-more only triggers on reaching the last page — no jump-to-end or density control. Wants 50–100 rows + persistent EPC/cost sort.
+
+**Sam (accessibility):** slate-300 "No cost"/"Unknown" fail AA outright; the quick-filter clear control is a `` nested *inside* a `` (invalid interactive nesting, unpredictable for SR/keyboard); the empty EpcLetterBubble is an unlabelled `
` with no "no data" text.
+
+**Riley (edge/empty-state stress):** the 185-no-plans grid is the headline failure — renders as a wall of placeholders with no explanation. Compounded by the delete modal's Cancel-with-no-Confirm dead-end (and `deletePreview` never populated, so the impact list is always empty), and load-more failing silently leaving a partial list.
+
+## Minor Observations
+
+- Give the empty EpcLetterBubble an aria-hidden "—" so the column isn't three invisible gaps.
+- `RESULTS:` in font-black uppercase is louder than the numbers it introduces — invert the weight.
+- Export button sits in `bg-slate-100` while neighbours are `bg-white` — reads as disabled when it's active.
+- The floating chat launcher (third-party) overlaps the right-edge Actions/⋯ column and can occlude the row menu.
+- Delete modal `DialogDescription` promises "Review the impact below" but `deletePreview` is never fetched in this file — always empty (engineering bug).
+- Heavy useEffect/useMemo usage contradicts the repo CLAUDE.md React guidance (for the engineering review, not design).
+
+## Questions to Consider
+
+1. If the default state of every new portfolio is "properties added, nothing modelled", why is that the state with zero design investment — shouldn't the unmodelled view be the primary design target?
+2. Three EPC columns collapse to three identical blank bubbles with no data — should Lodged/Expected be progressive-disclosure behind the modelled state?
+3. Two navy buttons say "both of these are the most important thing" — which ONE action is the product betting a first-time user should take, and does the layout make that bet visible?
diff --git a/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/DashboardSummaryCards.tsx b/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/DashboardSummaryCards.tsx
index 439b54a4..8f2ab4a8 100644
--- a/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/DashboardSummaryCards.tsx
+++ b/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/DashboardSummaryCards.tsx
@@ -12,7 +12,7 @@ import { Home, Zap, Leaf, LineChart, FileQuestionIcon } from "lucide-react";
import { formatNumber, sapToEpc } from "@/app/utils";
import type {
AverageMetrics,
- EstimatedCounts,
+ EpcCoverageCounts,
TotalMetrics,
ScenarioOverlayMetrics,
MetricKey,
@@ -66,18 +66,18 @@ export function DashboardSummaryCards({
total,
totals,
averages,
- estimatedCounts,
+ epcCoverage,
scenarioOverlay,
loading = false,
}: {
total: number;
totals: TotalMetrics;
averages: AverageMetrics;
- estimatedCounts: EstimatedCounts;
+ epcCoverage: EpcCoverageCounts;
scenarioOverlay?: ScenarioOverlayMetrics | null;
loading?: boolean;
}) {
- const missingEpcCount = estimatedCounts.estimated;
+ const missingEpcCount = epcCoverage.withoutEpc;
const missingEpcPercent = total > 0 ? (missingEpcCount / total) * 100 : 0;
const averageCurrentEpc = sapToEpc(averages.avg_sap || 0);
diff --git a/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/EpcQualityCards.tsx b/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/EpcQualityCards.tsx
index 89893137..6dc57604 100644
--- a/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/EpcQualityCards.tsx
+++ b/.sandcastle/worktrees/claude-assessment-model-p2/src/app/portfolio/[slug]/(portfolio)/reporting/EpcQualityCards.tsx
@@ -9,21 +9,21 @@ import {
} from "@/app/shadcn_components/ui/card";
import { motion } from "framer-motion";
import { FileQuestion, AlertTriangle, TrendingDown } from "lucide-react";
-import type { EstimatedCounts } from "./types";
+import type { EpcCoverageCounts } from "./types";
export function EpcQualityCards({
- estimatedCounts,
+ epcCoverage,
total,
expiredEpcs,
likelyDowngrades,
}: {
- estimatedCounts: EstimatedCounts;
+ epcCoverage: EpcCoverageCounts;
total: number;
expiredEpcs: number;
likelyDowngrades: number;
}) {
- // Missing EPCs (estimated = true)
- const missing = estimatedCounts.estimated;
+ // Homes with no certificate at all — neither lodged nor historical.
+ const missing = epcCoverage.withoutEpc;
const pctMissing = total > 0 ? (missing / total) * 100 : 0;
// Expired EPCs
@@ -39,7 +39,7 @@ export function EpcQualityCards({
icon: FileQuestion,
color: "text-red-600",
value: missing,
- subtitle: `${pctMissing.toFixed(1)}% missing EPC records`,
+ subtitle: `${pctMissing.toFixed(1)}% have no EPC on record`,
barColor: "bg-red-500",
barWidth: pctMissing,
gradient: "bg-gradient-to-br from-white to-red-50/20",
diff --git a/CONTEXT.md b/CONTEXT.md
index 09f36a20..09cc2cfd 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -101,15 +101,19 @@ A measure whose installation involves major internal works for residents (intern
_Avoid_: invasive (unused here), wet trades (a narrower, overlapping set: plaster-and-screed work)
**Measure exclusion**:
-A Scenario constraint that takes a measure off the table for the optimiser. The *only* measure-constraint concept on a Scenario — there is no stored inclusion list; "only Solar PV + ASHP" is expressed by excluding everything else. An empty exclusion set is valid and means every measure is available.
+A Scenario constraint that takes a measure off the table for the optimiser. The only measure-*exclusion* concept on a Scenario — there is no stored inclusion list; "only Solar PV + ASHP" is expressed by excluding everything else. An empty exclusion set is valid and means every measure is available. (Exclusions decide *which* measures are available; **Fabric first** decides the *order* they are considered — the two compose.)
_Avoid_: inclusions, allowed measures (as a stored concept — UI may present "allowed/excluded" toggles, but what's captured is the exclusion set)
+**Fabric first**:
+A Scenario constraint that forces the optimiser to apply every viable **fabric measure** (insulation, glazing, ventilation) before it will consider heating or renewables — the heating/renewables tier is reached only if the Scenario's upgrade target is still unmet once fabric is exhausted. Unlike a Measure exclusion (which removes a measure entirely), it constrains the *order* measures are considered, not which are on the table; the two compose (an excluded fabric measure simply isn't among those forced in). Off by default, set at creation and immutable like the rest of the config. The modelling backend owns the ordering logic and the fabric/heating split — the app only records the flag (trigger-payload field `enforce_fabric_first`).
+_Avoid_: fabric only (the quick-start that *excludes* heating/renewables outright — fabric-first still allows them as a fallback), sequencing/phasing (reserve for PIBI installation order), enforce fabric first (a UI verb on the toggle, not the domain noun)
+
**Modelling run**:
One user-initiated act of triggering modelling: a set of Scenarios crossed with one filter-defined property selection within a Portfolio. A durable record of *what was asked* — the Run filters, the Scenarios, who triggered it, when, and the matched-property count shown at preview — so Plans can be traced back to the selection that produced them, alongside how the work is going. A Scenario is the *question*; a Modelling run *asks* it (possibly again, possibly for a different property selection). Re-running an already-modelled property appends a newer Plan; latest wins on read.
_Avoid_: job, batch, trigger request, modelling task (the pipeline's execution records)
**Run filter**:
-The property-selecting constraints of a Modelling run: postcode, property type, and built form (each multi-select; tags later). An absent filter means *unconstrained* — "all postcodes" is the absence of a postcode filter, never an enumeration. Type and built form are the canonical enum vocabularies plus **Unknown**, which selects properties with no resolvable value at all. Resolution follows the Landlord-override rule: an override fact beats an EPC-derived value; the modelling backend is the single authority for resolving filters to properties (the app never re-implements the rule — matched counts come from the backend).
+The property-selecting constraints of a Modelling run: postcode, property type, built form, and **Tags** (each multi-select). An absent filter means *unconstrained* — "all postcodes" is the absence of a postcode filter, never an enumeration. Type and built form are the canonical enum vocabularies plus **Unknown**, which selects properties with no resolvable value at all; Tags are the Portfolio's own Tags (multi-select is **any-of**). Resolution follows the Landlord-override rule for type/built-form (an override fact beats an EPC-derived value) and a **direct membership lookup** for Tags — but in all cases the modelling backend is the single authority for resolving filters to properties (the app never re-implements the rule — matched counts come from the backend, which reads the same Tag membership the app writes). See [ADR-0013](./docs/adr/0013-tags-are-app-owned-property-groupings.md).
_Avoid_: property query, segment, search (the postcode-search journey is unrelated)
### Reporting
@@ -130,6 +134,26 @@ _Avoid_: PC cost, prelims
The reporting view of a Portfolio with no Scenario applied — every figure is Effective performance, aggregated. Also the "before" side of any scenario comparison ("Current → After scenario").
_Avoid_: baseline (reserved for property-level performance concepts), portfolio overview
+### Live projects
+
+**Project**:
+A delivery programme within a Portfolio — a batch of Properties taken through retrofit together — identified by its HubSpot **project code** (`hubspot_deal_data.project_code`; a stable **project id** will replace the code once the HubSpot ops board is settled, so the code is the *current* identifier, not the essence). A Property whose deal carries no project code sits outside every Project (the "Unknown Project" grouping) and cannot be reached by selecting Projects.
+_Avoid_: programme, scheme, deal group, batch (a **Batch** is a separate per-deal field)
+
+**Bulk document download**:
+An app-triggered, asynchronous assembly of a single ZIP of the documents held against a chosen set of Properties — picked as a row selection in the Documents tab, scoped by the tab's current Project/group — delivered as a time-limited link emailed to the requester (and, within the session, retrievable in-app). A selection that matches no documents produces no ZIP: it fails rather than emailing an empty archive. Properties are matched to their documents by **landlord property id**. See [ADR-0011](./docs/adr/0011-app-owned-task-marker-in-task-source.md).
+_Avoid_: bulk export, document export, zip download
+
+### Tags
+
+**Tag**:
+A user-created, coloured label owned by a Portfolio, used to form an arbitrary **group** of its Properties for bulk actions (e.g. running Scenarios over the group, or excluding it from a Reporting view). Flat (no hierarchy) and many-to-many: a Property carries zero or more Tags, and a Tag labels zero or more Properties. Distinct from a **Project** (a HubSpot-sourced grouping, at most one per Property) and from a **Scenario** (a modelling question): a Tag is an app-owned, hand-curated selection with no external source and no modelling semantics of its own.
+_Avoid_: label, category, group (the group is the *effect* of a Tag, not a separate entity), segment, tag group
+
+**Bulk tag assignment**:
+Assigning one Tag to many Properties at once from a small uploaded file (CSV/Excel) of property identifiers — either **landlord property id** or **UPRN**, whichever column the file carries. Parsed and matched entirely in the app (no FastAPI pipeline); the target Tag is chosen in the upload dialog, not named in the file. An identifier that matches no Property is reported back (never silently dropped); an already-tagged match is a no-op. The parallel filter-driven path assigns a Tag to **every Property matching the current property-table filter**.
+_Avoid_: tag import, bulk tagging (verb is fine; the noun is Bulk tag assignment)
+
## Lifecycle
A **BulkUpload** moves through these statuses:
@@ -181,11 +205,29 @@ The act of substituting a corrected set of performance metrics in place of the L
_Avoid_: override, adjustment, correction
**EPC provenance** (`epc_property.source`):
-Whether a property's EPC picture is a real certificate or a gap-fill. `lodged` = a real public/landlord EPC exists; `predicted` = no certificate, so the EPC was estimated from nearby properties (EPC Prediction gap-fill). Independent of Rebaseline: a `lodged` property may still be rebaselined, and a `predicted` property still carries Lodged-performance figures (mirrored estimates), so the presence of `lodged_*` columns does **not** imply a real certificate — only `source = lodged` does.
+Whether a property's EPC picture is a real certificate or a gap-fill. Three values:
+- `lodged` — a real, current public/landlord EPC exists.
+- `predicted` — no certificate exists anywhere, so the EPC was gap-filled from nearby properties (EPC Prediction).
+- `expired` — also gap-filled, but conditioned on **this dwelling's own expired certificate** from the historic register (Model ADR-0054). The gov EPC API only serves certificates registered since 2012, so a pre-2012 dwelling looks EPC-less to ingestion even though a real, stale certificate exists for it.
+
+Independent of Rebaseline: a `lodged` property may still be rebaselined, and a gap-filled property still carries Lodged-performance figures (mirrored estimates), so the presence of `lodged_*` columns does **not** imply a real certificate — only `source = lodged` does.
+_Avoid_: estimated EPC (reserve "estimated" for the UI signal), source EPC
+
+**Predicted slot**:
+`predicted` and `expired` are two flavours of one slot — a property holds at most one of them, and a re-ingestion may flip which. Every query must therefore address the **slot** (`source IN ('predicted','expired')`), never a single member: matching `source = 'predicted'` alone makes `expired` rows invisible, and since `epc_property.source` is plain `text` with no enum or CHECK constraint, nothing catches it. Mirrors `PREDICTED_SLOT_SOURCES` in the Model repo. See [ADR-0014](./docs/adr/0014-epc-cards-count-certificates-not-predictions.md).
+_Avoid_: predicted source (it is two sources)
+
+**EPC coverage** — *does any certificate exist for this dwelling?*
+`lodged` **or** `expired` ⇒ yes, one does (current, or out of date). `predicted`, or no `epc_property` rows at all ⇒ no, none does.
+
+This is a **different question** from provenance's "was the picture modelled?" — an `expired` property is gap-filled *and* has a certificate. Conflating the two is what made the reporting cards wrong: the "Homes Without an EPC" card counted every gap-fill, so homes whose only fault was an out-of-date certificate were reported as having no EPC at all. The cards partition on coverage, not on provenance.
+_Avoid_: missing EPC (ambiguous — say "without an EPC" for coverage, "estimated" for provenance)
_Avoid_: estimated EPC (reserve "estimated" for the UI signal), source EPC
**Provenance signal** (UI):
-What the user is told about an EPC's trustworthiness, derived from EPC provenance and Rebaseline together: **Estimated** (`source = predicted` — dominant; "estimated based on nearby homes") › **Re-modelled** (`source = lodged AND rebaseline_reason != none` — effective diverged from the lodged certificate under SAP 10) › **none** (`source = lodged AND rebaseline_reason = none` — effective equals lodged). Estimated always wins when both could apply.
+What the user is told about an EPC's trustworthiness, derived from EPC provenance and Rebaseline together: **Estimated** (`source IN (predicted, expired)` — the whole predicted slot, dominant; "estimated based on nearby homes") › **Re-modelled** (`source = lodged AND rebaseline_reason != none` — effective diverged from the lodged certificate under SAP 10) › **none** (`source = lodged AND rebaseline_reason = none` — effective equals lodged). Estimated always wins when both could apply.
+
+An `expired` property is **Estimated**: its picture was modelled, not read off a current certificate. That it *also* has an (out-of-date) certificate is a matter of EPC coverage, which the reporting cards use — not of this signal.
_Avoid_: estimation notification, banner (those are component names)
**Likely downgrade**:
@@ -208,6 +250,7 @@ _Avoid_: quick win, free upgrade
## Flagged ambiguities
+- The portfolio **Property table**'s **Property Type**, **Built Form**, **Construction Age**, **Main Fuel**, **Wall Type**, **Roof Type** and **Heating System** columns show the **landlord-override-resolved** value — the same precedence the modelling **Run filter** applies (override fact → EPC-derived → **Unknown**) — not the raw `epc_property` value or the legacy property-row column. See [ADR-0012](./docs/adr/0012-portfolio-list-resolves-descriptors-via-override-precedence.md). All seven are also **filters**, and the per-part ones (wall/roof) read the **main building part**. Wall/Roof/Heating filter by **coarse bucket** rather than the full vocabulary — their resolved values are free-text (override vocab / EPC `epc_energy_element.description` / legacy column) with hundreds of variants, so a fixed set of prefix/substring buckets (Wall → Cavity / Solid Brick / Timber Frame / Stone / …; Roof → Pitched / Flat / Room-in-Roof / …; Heating → Gas Boiler / Community / Electric Storage / Heat Pump / …) matches them, while the columns still **display the full description**. `classifyDescriptor` is the pure twin of the SQL bucketing. Two label subtleties: **Construction Age** is an RdSAP band (e.g. "1900–1929", "before 1900"), never a single year (it was formerly the "Year Built" column); and **Main Fuel** for new-approach properties reads the EPC's `epc_main_heating_detail.main_fuel_type` (an RdSAP `main_fuel` code or an EPR string, folded to a coarse label) beneath any landlord override — it only reads **Unknown** when neither is present.
- The UI surfaces labelled **"Current EPC"** and **"Current Efficiency State"** (property table, building-passport card) show **Effective performance**, not Lodged — despite the glossary advising against "current performance" for Effective. The label is a product choice ("current" = the property's true present-day modelled state); the underlying datum is still **Effective performance**. The **"Lodged EPC"** column/badge is the only surface showing **Lodged performance**, and only when a real certificate exists (`source = lodged`).
- "Upload" is used in the codebase to mean both the file-on-S3 and the BulkUpload row. We standardise on **BulkUpload** for the row; the file is just "the source file."
- "Onboarding" appears in some route paths (`bulk_onboarding_inputs/...`) but isn't part of this glossary — we use **BulkUpload** end-to-end.
diff --git a/docs/adr/0007-postcode-search-creates-properties.md b/docs/adr/0007-postcode-search-creates-properties.md
index ca158d4b..614d110a 100644
--- a/docs/adr/0007-postcode-search-creates-properties.md
+++ b/docs/adr/0007-postcode-search-creates-properties.md
@@ -35,9 +35,13 @@ modelling exists.
distinguishable.
- **Deterministic mapping** (fixed table, tested): RD02→House+Detached,
RD03→House+Semi-Detached, RD04→House (Mid/End unknowable — no built form),
- RD06→Flat, RD07→House. Every other code maps nothing; `Unknown` is never
+ RD06→Flat, RD07→House, RH01/RH02/RH03→House (the dedicated HMO family, built
+ form unknowable). Every other code maps nothing; `Unknown` is never
written (absence, not noise) — preserving the finaliser's invariant. The
backend's predict-EPC service consumes these for archetype matching.
+- **Addable codes**: the RD (dwelling) family except RD10 (institutions), plus
+ the RH (HMO) family. All other codes — commercial, institutional, land — are
+ not addable and render "Non-residential".
- **Read-through cache** on the existing `postcode_search` jsonb table:
serve when fresher than 30 days, else refresh from OS Places and upsert.
diff --git a/docs/adr/0011-app-owned-task-marker-in-task-source.md b/docs/adr/0011-app-owned-task-marker-in-task-source.md
new file mode 100644
index 00000000..01534378
--- /dev/null
+++ b/docs/adr/0011-app-owned-task-marker-in-task-source.md
@@ -0,0 +1,46 @@
+# 11. App-owned, backend-executed tasks carry their marker in `task_source`
+
+Date: 2026-07-08
+
+## Status
+
+Accepted
+
+## Context
+
+Bulk document download follows the app-created-task convention (ADR-0008): Next.js
+inserts a `tasks` row whose `inputs` column carries the selection config, then hands
+the backend only `{ task_id }`. Unlike a Modelling run — where the distributor
+receives the whole config in the dispatch payload and never looks at the task again —
+the document worker gets *only* the id, re-reads the `tasks` row, and resolves the
+selection from `inputs`. It therefore needs a durable, in-row way to recognise "this
+is a bulk-document-download task I'm allowed to act on" before it assembles anything.
+
+Modelling runs put that marker in `service` (`modelling_run`) and leave `task_source`
+human-readable (`"Modelling run – 2 scenarios"`). Reusing `service` here would work,
+but it invites a future engineer to "unify" the two conventions and move the marker —
+silently breaking the worker's guard.
+
+## Decision
+
+- **The marker is `task_source = "app:bulk_document_download"`** — a single, stable
+ string the worker guards on. The `app:` prefix denotes an app-created task (as
+ opposed to a backend-created one). It is engineer-facing only (Settings → Logs), so
+ a machine-shaped string is acceptable; no friendly-label mapping is added.
+- **`service` is left null.** For a task whose marker already lives in `task_source`,
+ a second marker in `service` is redundant and can drift. In-app status polling
+ scopes by `id = task_id AND source_id = AND task_source =
+ "app:bulk_document_download"`.
+- **Portfolio attachment is unchanged and uniform:** `source = "portfolio_id"`,
+ `source_id = `. This is what the Portfolio Logs page filters on, so
+ the run shows up there for free — the same as every other app-owned task.
+
+## Consequences
+
+- Do **not** move this marker into `service` to match Modelling runs. The asymmetry is
+ deliberate: the marker lives where the executor reads it — `service` for a
+ payload-fed distributor, `task_source` for a task-re-reading worker.
+- A large selection never travels in an HTTP body: it lives in `inputs`, and the only
+ thing dispatched is `task_id` (ADR-0008 lineage).
+- Future app-owned, backend-executed tasks should follow this shape:
+ `task_source = "app:"`, config in `inputs`, `source`/`source_id` for scoping.
diff --git a/docs/adr/0012-portfolio-list-resolves-descriptors-via-override-precedence.md b/docs/adr/0012-portfolio-list-resolves-descriptors-via-override-precedence.md
new file mode 100644
index 00000000..08f4c461
--- /dev/null
+++ b/docs/adr/0012-portfolio-list-resolves-descriptors-via-override-precedence.md
@@ -0,0 +1,89 @@
+# 12. The portfolio property-list resolves descriptors through the landlord-override precedence
+
+Date: 2026-07-10
+
+## Status
+
+Accepted
+
+## Context
+
+The portfolio property-list's **Property Type**, **Built Form**, **Year Built**
+and **Main Fuel** columns and filters read raw `property` row columns (and, for
+main fuel, the legacy `property_details_epc` table). Those columns are NULL for
+**new-approach** properties (`property.updated_at >= 2026-06-01`, the EPC-graph
+cutoff — see `epcSources.ts`), so for any new portfolio the columns render blank
+and the filters match nothing. The already-migrated columns (current/lodged EPC,
+floor area, CO₂, provenance, expiry) route through `epcSources` fragments and
+work; these four were simply never migrated.
+
+Separately, [ADR-0008](./0008-modelling-runs-filters-to-distributor.md)
+established the resolution precedence for the modelling **Run filter**:
+**landlord-override fact → EPC-derived value (new-approach graph, lodged over
+predicted, RdSAP codes mapped; legacy property-row fallback) → Unknown**. It is
+implemented in-app inline in `previewModellingRun` and mirrored by the
+distributor; divergence between the two is defined as a bug.
+
+## Decision
+
+The portfolio list resolves Property Type, Built Form, Construction Age and Main
+Fuel through the **same override precedence as the Run filter**, so the browse
+surface agrees with what a modelling run would actually select. Concretely:
+
+- **Shared fragments, one home for the rule.** `epcSources.ts` gains
+ `overrideJoins` (LEFT JOINs of `property_overrides` aliased per component at
+ `building_part = 0`) and `resolvedPropertyTypeSql` / `resolvedBuiltFormSql` /
+ `resolvedConstructionBandSql` / `resolvedMainFuelSql`. Both the list query and
+ `previewModellingRun` consume them; the inline COALESCE in
+ `previewModellingRun` is refactored onto the shared fragments.
+- **Never-null.** Each fragment is `COALESCE(override, epcSql, 'Unknown')`. Every
+ property resolves to a concrete, filterable string; the **Unknown** filter chip
+ matches "no resolvable value at all" — character-for-character the semantics
+ CONTEXT.md already gives the Run filter's Unknown. The list columns render an
+ explicit **Unknown** pill instead of a blank `—`.
+- **Construction Age is band-native, not a year.** Override and EPC both store
+ the RdSAP band **letter** (`A..M`, `Unknown`); the field resolves in letter
+ space and displays the band **label** ("before 1900", "1900–1929", … "2023
+ onwards"). A numeric year cannot represent an `Unknown` override and misreads a
+ band as a precise year. The column is **renamed "Year Built" → "Construction
+ Age"** and its filter options become the bands, not years; legacy raw years are
+ bucketed into bands.
+- **Main Fuel is override-only for new-approach.** The EPC graph exposes no clean
+ main-fuel string (a documented `epcSources` gap → NULL), so for new-approach
+ properties the override is the *only* source; unoverridden properties read
+ **Unknown**. The override vocabulary (`"mains gas"`, `"LPG (bulk)"`, …) is
+ folded into the existing collapsed filter labels (Mains Gas, LPG, …).
+- **`tenure` is removed from the list**, not fixed. It has no override component,
+ and its `epc_property.tenure` values don't cleanly reconcile with the filter's
+ `dbValues`. It is dropped from the list column and filter only;
+ `resolvePropertyMeta`/`resolvePropertyDescriptors` still resolve it for the
+ per-property building passport, and `property.tenure` is retained.
+
+## Alternatives considered
+
+- **EPC-derived only, no overrides.** Smaller, and consistent with how the other
+ already-migrated columns behave. Rejected: the list would then disagree with
+ the modelling Run filter — e.g. show "Flat" for a property a landlord override
+ makes (and modelling treats as) "Maisonette" — reintroducing exactly the
+ browse-vs-model mismatch this work set out to remove.
+- **Construction Age as a numeric year.** Familiar and a smaller diff. Rejected:
+ cannot represent an `Unknown` override (collapses to `—`, breaking the
+ never-null contract) and misrepresents a band as a point year.
+- **Keep the precedence rule inline in `previewModellingRun` and duplicate it in
+ the list.** Avoids touching a working feature. Rejected: it re-creates the
+ two-homes divergence ADR-0008 explicitly warns against — now within the app.
+
+## Consequences
+
+- The count query (`getPropertiesCount`) must join `property_overrides` when any
+ of these fields is filtered — `EPC_JOIN_FILTER_FIELDS` (or a sibling set) is
+ extended. Joins are perf-sensitive (the count path already brushes Vercel's
+ 15s limit), so the joins stay conditional on an active filter.
+- Every new-approach property without a main-fuel override shows **Unknown** — a
+ lot of Unknown pills, but an honest signal of the EPC gap rather than a blank
+ implying "not applicable".
+- Filter option lists grow: Property Type gains **Park home** + **Unknown**;
+ Built Form gains **Unknown** (keeping **Not Recorded** for the explicit
+ override); Main Fuel folds the override vocab into existing labels.
+- `previewModellingRun` and the portfolio list are now provably in sync — the
+ shared fragment is the single reference implementation ADR-0008 asked for.
diff --git a/docs/adr/0013-tags-are-app-owned-property-groupings.md b/docs/adr/0013-tags-are-app-owned-property-groupings.md
new file mode 100644
index 00000000..e139908a
--- /dev/null
+++ b/docs/adr/0013-tags-are-app-owned-property-groupings.md
@@ -0,0 +1,101 @@
+# 13. Tags are app-owned Property groupings, filtered in-app and passed to modelling as a filter key
+
+Date: 2026-07-13
+
+## Status
+
+Accepted
+
+Numbering note: 0010 (reporting redesign) and 0012 (portfolio-list descriptor
+resolution) are accepted on their own in-flight branches; 0013 avoids collision
+with both.
+
+## Context
+
+Users need to form **arbitrary, hand-curated groups** of a Portfolio's
+Properties to drive bulk actions — running Scenarios over a subset, and (later)
+including/excluding a group from Reporting. Nothing existing covers this:
+
+- **Projects** (ADR: HubSpot-sourced) are at most one per Property and owned by
+ an external system — not user-curated, not many-per-property.
+- **Run filters** (ADR-0008) select by postcode / property type / built form —
+ data-derived facts, not a free-form selection.
+
+ADR-0008 already anticipated this: it kept the distributor's filter payload a set
+of tiny keys resolved against the shared Postgres, **explicitly rejected sending
+resolved property-id lists** (~50k ids overflow the async entry point and move
+resolution into the app), and reserved that "tags become one more optional
+filter key."
+
+## Decision
+
+- **A Tag is a flat, app-owned, Portfolio-scoped label**, many-to-many with
+ Property (`portfolio_tag`, `property_tag`). No hierarchy, no external source,
+ no modelling semantics of its own — it exists only to name a group. See
+ CONTEXT.md (Tag).
+- **Assignment has four paths, all app-owned:** a per-Property inline editor; a
+ filter-driven "tag everything matching the current property-table filter";
+ a row-multiselect (whose "select all matching" delegates to the filter path);
+ and a **Bulk tag assignment** file upload.
+- **The bulk upload is parsed and matched entirely in the app — no FastAPI
+ pipeline.** The BulkUpload pipeline exists to match *arbitrary addresses* to
+ UPRNs and to *classify free text*; tag assignment matches an *existing
+ identifier* (landlord property id **or** UPRN, whichever column the file
+ carries) to *existing* Properties in one Portfolio. There is no address
+ matching and no classification, and the files are small — so the pipeline's
+ cost (S3 round-trip, async task, combiner) buys nothing. An unmatched
+ identifier is reported, never silently dropped; an ambiguous landlord id (they
+ are **not** unique per Portfolio) tags every match and says so.
+- **Tags reach modelling as a `tag_ids` filter key (extends ADR-0008), never as
+ a property-id list.** `RunFilters` gains `tag_ids`; it is **AND-combined**
+ with the other filter dimensions and **OR-within** (any-of), matching the
+ property-table filter. The app computes the in-app preview count by joining
+ `property_tag` (the reference implementation ADR-0008 requires); the
+ distributor resolves the same key by the same join against the shared DB it
+ already reads. This needs one backend change — the distributor learning
+ `tag_ids` — so the app side ships first and scenarios-on-tags goes live when
+ the backend lands.
+- **The property-table Tag filter is app-resolved** (unlike modelling, the app
+ owns the browse surface): a dynamic per-Portfolio option list, any-of, plus a
+ synthetic **Untagged** option (zero memberships).
+- **Delete is hard + cascade.** Removing a Tag drops its memberships behind a
+ confirm that shows the count. A Tag id baked into a past Run's stored filter
+ becomes dangling and renders as "(deleted tag)" in Run history — no archive
+ state to query around.
+- **Schema migrations ship in their own PR**, separate from the feature code
+ (project convention).
+
+## Alternatives considered
+
+- **Two-level Tag Group → Tag hierarchy.** More expressive (mutually-exclusive
+ groups), but every stated use case is served by flat Tags with far less schema
+ and UI; grouping can be added later without reshaping the join.
+- **Reuse Projects as the grouping.** No new tables, but Projects are
+ HubSpot-owned, one-per-Property, and not user-editable — the opposite of what a
+ Tag is.
+- **App resolves `tag_ids` → property-id list for the run.** No backend change,
+ but re-runs exactly what ADR-0008 rejected: an unbounded payload and the
+ resolution rule living in the app, where preview and run can drift.
+- **Route the bulk upload through the FastAPI BulkUpload pipeline.** Reuses the
+ existing async machinery, but pays for address-matching and classification the
+ task doesn't need, and couples a simple in-Portfolio identifier join to a
+ multi-stage S3 pipeline.
+- **Soft-delete / archive Tags.** Preserves history references exactly, but
+ burdens every Tag query with an `archived` predicate for a gain a
+ "(deleted tag)" label already covers.
+
+## Consequences
+
+- **One backend ask** must land for scenarios-on-tags to work end-to-end: the
+ distributor accepts and resolves a `tag_ids` filter key against `property_tag`,
+ mirroring the app's preview. Until then the run UI can show and preview a Tag
+ selection but the run won't scope by it.
+- **Reporting-by-tag is deferred to the reporting redesign** (PRD #370 /
+ ADR-0010): the substrate (`property_tag`) ships now; "include/exclude a tagged
+ group" becomes a requirement of that redesign rather than a retrofit onto the
+ scenario-aggregate reporting it replaces.
+- A deleted Tag leaves a dangling id in any Run-history record that referenced
+ it; history reads must tolerate it (render "(deleted tag)").
+- `landlord_property_id` is partial (~43% of Properties) and non-unique per
+ Portfolio, so bulk uploads that use it cover less than half the Portfolio and
+ can tag duplicates — UPRN is offered as the reliable alternative key.
diff --git a/docs/adr/0014-epc-cards-count-certificates-not-predictions.md b/docs/adr/0014-epc-cards-count-certificates-not-predictions.md
new file mode 100644
index 00000000..c8a8b87c
--- /dev/null
+++ b/docs/adr/0014-epc-cards-count-certificates-not-predictions.md
@@ -0,0 +1,105 @@
+# The EPC reporting cards count certificates, not predictions
+
+## Status
+
+accepted
+
+## Context
+
+The portfolio reporting page shows two EPC-quality cards: **Homes Without an EPC**
+and **Expired EPCs**. Both were derived from `estimatedSql`, which asked *"is this
+property's EPC picture a gap-fill?"*:
+
+```sql
+-- "Homes Without an EPC"
+SUM(CASE WHEN estimatedSql = true THEN 1 ELSE 0 END)
+-- "Expired EPCs"
+SUM(CASE WHEN isExpiredSql = true AND estimatedSql = false THEN 1 ELSE 0 END)
+```
+
+That conflates two genuinely different questions:
+
+- **Provenance** — was this picture *modelled*, or read off a real certificate?
+- **Coverage** — does a certificate *exist* for this dwelling at all?
+
+They used to give the same answer, because `epc_property.source` had two values and
+a gap-fill implied no certificate. That stopped being true.
+
+The gov EPC API only serves certificates registered since **1 January 2012**. A
+dwelling whose only certificate predates that looks EPC-less to ingestion, so its
+picture gets gap-filled — even though a real, if stale, certificate exists for it in
+the historic register. Model ADR-0054 introduced a third `source` value, `expired`,
+for exactly this case: a prediction *conditioned on the dwelling's own expired
+certificate*. `predicted` and `expired` share one slot (`PREDICTED_SLOT_SOURCES`).
+
+Measured on portfolio 824 (5,276 homes): **403** homes were gap-filled, and **375**
+of them have a real pre-2012 certificate in the historic backup. So the card claimed
+403 homes had no EPC when 375 of them did — they just had an out-of-date one, which
+is a different and far more actionable problem. It is also the *wrong* problem to
+solve: you do not commission a new EPC survey for a home you believe has never been
+certified in the same way you chase a lapsed one.
+
+Two further defects fell out of the same conflation:
+
+- `epc_property.source` is plain `text` with **no enum and no CHECK constraint**, and
+ every query matched `source = 'predicted'` literally. An `expired` row matches
+ neither the lodged nor the predicted alias, so the home would have read as though it
+ held a *valid current certificate* — silently absent from **both** cards, with no
+ Estimated badge. Nothing in the database would have caught this.
+- `isExpiredSql` read `epl.registration_date` alone, but 714 of 824's 4,873 lodged
+ certificates carry only an `inspection_date`. All 714 were treated as current; 170
+ of them are in fact over ten years old. (`lodgementDateSql` already coalesced the
+ two — the expiry predicate simply didn't.)
+
+## Decision
+
+**The two cards partition on coverage, not provenance.** A prediction is not a
+certificate; an expired certificate is still a certificate.
+
+- `withoutEpcSql` — *no lodgement record and no historical record*:
+ `epl.id IS NULL AND epx.id IS NULL`. A blind `predicted` row is not evidence of an
+ EPC, so it is not consulted. A property with no `epc_property` rows at all also
+ lands here, correctly.
+- `isExpiredSql` — *we found a certificate, of either kind, and it is out of date*:
+ an `expired` row (>10 years old by construction, since its conditioning certificate
+ predates 2012), **or** a lodged certificate older than ten years, dating it by
+ `COALESCE(registration_date, inspection_date)`.
+- `estimatedSql` keeps its own, separate meaning — *was this modelled?* — and now
+ spans the whole predicted slot, so an `expired` home still carries the **Estimated**
+ provenance badge. It is estimated **and** has an EPC. Both are true.
+
+The `AND estimated = false` guard is removed from the Expired card and must stay
+removed: an `expired` home *is* estimated, so the guard would exclude precisely the
+homes the card exists to count. The rule it was really enforcing — *a gap-fill has no
+certificate to expire* — now lives inside `isExpiredSql`, where a caller cannot forget
+it.
+
+**Every query addresses the predicted slot (`epp` OR `epx`), never one member.**
+
+## Consequences
+
+Legacy properties (`updated_at` before the 2026-06-01 cutoff) are **unaffected** —
+they have no `epc_property` rows and keep reading the flat `property_details_epc`
+flags. Portfolio 632 reports 8 / 1,662 before and after.
+
+For new-approach properties the numbers move, in two steps. The `inspection_date`
+fallback lands immediately and is a straight bug fix: 824's Expired count goes
+**913 → 1,083**. Then, once Model starts writing `expired` rows, the cards settle at
+**403 → 25** without an EPC and **1,083 → 1,461** expired. The portfolio has not
+changed; we were miscounting it.
+
+This repo is safe to deploy **before** Model starts writing `expired` rows — the
+predicates simply find none. The reverse is not true: had Model shipped first, every
+`expired` home would have gone quietly missing from both cards.
+
+Two things we accept:
+
+- **The three-way reality is still squashed into booleans per card.** We do not
+ surface "has an expired certificate" and "has nothing at all" as distinct states
+ anywhere except by the two cards being disjoint. If a third state ever needs its own
+ treatment, this is where to add it.
+- **Nothing enforces the slot at the database level.** `source` remains `text`. A
+ future query that matches `source = 'predicted'` alone would reintroduce the bug in
+ silence. `src/lib/services/epcSlot.test.ts` pins the invariant structurally; a CHECK
+ constraint or a Postgres enum would be stronger, and is worth doing when the schema
+ is next touched.
diff --git a/docs/backend-asks/tag-ids-run-filter.md b/docs/backend-asks/tag-ids-run-filter.md
new file mode 100644
index 00000000..3212d50c
--- /dev/null
+++ b/docs/backend-asks/tag-ids-run-filter.md
@@ -0,0 +1,73 @@
+# Backend ask — resolve a `tag_ids` Run-filter key
+
+**For:** the distributor (`POST /v1/modelling/trigger-run`)
+**From:** the portfolio tagging system (app), ADR-0013 (extends ADR-0008)
+**Status:** app side built; backend change outstanding
+
+## What's needed
+
+The modelling **Run filter** gains one optional key, `tag_ids` — a list of
+portfolio Tag ids. The distributor already receives
+`{ task_id, portfolio_id, scenario_ids, filters }` and resolves `filters`
+against the shared Postgres. It must now also resolve `tag_ids`.
+
+```jsonc
+// dispatch payload (unchanged except the new optional filters key)
+{
+ "portfolio_id": 814,
+ "scenario_ids": [12, 34],
+ "filters": {
+ "postcodes": ["B93 8SU"], // existing
+ "property_types": ["House"], // existing
+ "built_forms": ["Detached"], // existing
+ "tag_ids": [7, 3] // NEW — optional
+ }
+}
+```
+
+## Resolution rule
+
+Tags are a **direct membership** lookup, not the override→EPC precedence used for
+type/built-form. A property matches `tag_ids` when it has a row in
+`property_tag` for any of the ids (**any-of**). Combine with the other filter
+dimensions the same way they combine today: **AND across dimensions, OR within**.
+
+```sql
+-- add to the property-matching WHERE, only when tag_ids is present:
+p.id IN (
+ SELECT pt.property_id FROM property_tag pt
+ WHERE pt.tag_id IN (:tag_ids)
+)
+```
+
+Tables (already migrated — see PR #387 / migration `0271`):
+
+- `portfolio_tag(id, portfolio_id, name, colour, …)`
+- `property_tag(property_id, tag_id)` — PK `(property_id, tag_id)`, index
+ `ix_property_tag_tag` on `tag_id` for exactly this reverse lookup.
+
+Ids that don't belong to the portfolio simply match nothing (no validation
+needed). An absent/empty `tag_ids` means unconstrained, like the other keys.
+
+## Reference implementation (must stay in lock-step)
+
+The app's in-app **preview count** is the reference implementation ADR-0008
+requires — the distributor's resolution must match it. See
+`previewModellingRun` in `src/lib/modellingRuns/server.ts`: the tag clause is
+
+```ts
+conditions.push(
+ sql`resolved.id IN (SELECT pt.property_id FROM property_tag pt
+ WHERE pt.tag_id IN (${inList(args.filters.tagIds)}))`,
+);
+```
+
+Divergence between the app preview and the distributor is defined as a bug
+(ADR-0008).
+
+## Until this lands
+
+The run UI can show and preview a Tag selection (the app resolves the preview),
+but a triggered run won't scope by tags until the distributor resolves
+`tag_ids`. No contract-shape change is needed on either side beyond reading the
+new key.
diff --git a/src/app/api/portfolio/[portfolioId]/bulk-document-download/[taskId]/route.ts b/src/app/api/portfolio/[portfolioId]/bulk-document-download/[taskId]/route.ts
new file mode 100644
index 00000000..fef05d07
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/bulk-document-download/[taskId]/route.ts
@@ -0,0 +1,31 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getServerSession } from "next-auth";
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { getBulkDownloadStatus } from "@/lib/bulkDocumentDownload/server";
+
+// GET — status of a triggered bulk download, for in-app polling. Reads the
+// worker's sub_task.outputs (presigned URL, included count, skipped list).
+export async function GET(
+ _request: NextRequest,
+ props: { params: Promise<{ portfolioId: string; taskId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session?.user?.email) {
+ return NextResponse.json({ error: "Unauthorised" }, { status: 401 });
+ }
+ const { portfolioId, taskId } = await props.params;
+ if (!/^\d+$/.test(portfolioId)) {
+ return NextResponse.json({ error: "Invalid portfolio id" }, { status: 400 });
+ }
+
+ try {
+ const status = await getBulkDownloadStatus(portfolioId, taskId);
+ if (!status) {
+ return NextResponse.json({ error: "Not found" }, { status: 404 });
+ }
+ return NextResponse.json(status);
+ } catch (err) {
+ console.error("GET /bulk-document-download/[taskId] error:", err);
+ return NextResponse.json({ error: "Internal server error" }, { status: 500 });
+ }
+}
diff --git a/src/app/api/portfolio/[portfolioId]/bulk-document-download/route.ts b/src/app/api/portfolio/[portfolioId]/bulk-document-download/route.ts
new file mode 100644
index 00000000..564206df
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/bulk-document-download/route.ts
@@ -0,0 +1,82 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getServerSession } from "next-auth";
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { z } from "zod";
+import { triggerBulkDocumentDownload } from "@/lib/bulkDocumentDownload/server";
+
+// The document service resolves the selection and creates its sub_task
+// synchronously before returning 202, which can outrun the default function
+// budget on large projects. Give the round-trip headroom so the browser gets
+// our JSON (202 / mapped error) rather than a platform 504.
+export const maxDuration = 60;
+
+const scopeSchema = z.union([
+ z.object({ kind: z.literal("project"), projectCode: z.string().min(1) }),
+ z.object({
+ kind: z.literal("all-projects"),
+ projectCodes: z.array(z.string().min(1)),
+ }),
+]);
+
+const bodySchema = z.object({
+ scope: scopeSchema,
+ includeAll: z.boolean(),
+ landlordPropertyIds: z.array(z.string().min(1)).default([]),
+});
+
+function sessionToken(request: NextRequest): string | undefined {
+ return (
+ request.cookies.get("__Secure-next-auth.session-token")?.value ??
+ request.cookies.get("next-auth.session-token")?.value
+ );
+}
+
+// POST — record + dispatch a bulk document download (ADR-0008 convention)
+export async function POST(
+ request: NextRequest,
+ props: { params: Promise<{ portfolioId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session?.user?.email) {
+ return NextResponse.json({ error: "Unauthorised" }, { status: 401 });
+ }
+ const { portfolioId } = await props.params;
+ if (!/^\d+$/.test(portfolioId)) {
+ return NextResponse.json({ error: "Invalid portfolio id" }, { status: 400 });
+ }
+
+ let body: z.infer;
+ try {
+ body = bodySchema.parse(await request.json());
+ } catch {
+ return NextResponse.json({ error: "Invalid body" }, { status: 400 });
+ }
+
+ try {
+ const outcome = await triggerBulkDocumentDownload({
+ selection: {
+ scope: body.scope,
+ includeAll: body.includeAll,
+ landlordPropertyIds: body.landlordPropertyIds,
+ portfolioId: Number(portfolioId),
+ },
+ sessionToken: sessionToken(request),
+ });
+ switch (outcome.kind) {
+ case "ok":
+ return NextResponse.json({ taskId: outcome.taskId }, { status: 202 });
+ case "invalid_selection":
+ return NextResponse.json({ error: outcome.message }, { status: 400 });
+ case "backend_error":
+ // Pass the backend's status (400 over-cap / 409 already-started / 5xx)
+ // and its detail message straight through.
+ return NextResponse.json(
+ { error: outcome.message },
+ { status: outcome.status },
+ );
+ }
+ } catch (err) {
+ console.error("POST /bulk-document-download error:", err);
+ return NextResponse.json({ error: "Internal server error" }, { status: 500 });
+ }
+}
diff --git a/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/address-corrections/route.ts b/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/address-corrections/route.ts
new file mode 100644
index 00000000..6ae418fa
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/address-corrections/route.ts
@@ -0,0 +1,43 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getServerSession } from "next-auth";
+import { z } from "zod";
+
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { upsertUprnCorrection } from "@/lib/bulkUpload/addressMatches";
+
+// Confirm one flagged combiner row (ADR-0057): either assign a UPRN chosen from
+// OS Places, or assert the address has none. Keyed by `source_row_id` (there is
+// no property.id yet — the finaliser creates identities). Upsert semantics, so
+// re-confirming overwrites. The confirmation is overlaid onto the combiner CSV
+// at dispatchFinaliser.
+const AssignSchema = z.object({
+ sourceRowId: z.string().min(1),
+ uprn: z.string().regex(/^\d+$/, "UPRN must be numeric"),
+ address: z.string().min(1),
+ postcode: z.string().min(1),
+});
+const NoUprnSchema = z.object({
+ sourceRowId: z.string().min(1),
+ markedNoUprn: z.literal(true),
+});
+const BodySchema = z.union([NoUprnSchema, AssignSchema]);
+
+export async function POST(
+ request: NextRequest,
+ { params }: { params: Promise<{ portfolioId: string; uploadId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
+
+ const { uploadId } = await params;
+ const parsed = BodySchema.safeParse(await request.json().catch(() => null));
+ if (!parsed.success) {
+ return NextResponse.json(
+ { error: parsed.error.issues[0]?.message ?? "Invalid request" },
+ { status: 400 },
+ );
+ }
+
+ await upsertUprnCorrection(uploadId, parsed.data, session.user?.email ?? undefined);
+ return NextResponse.json({ ok: true }, { status: 200 });
+}
diff --git a/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/address-matches/route.ts b/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/address-matches/route.ts
new file mode 100644
index 00000000..a585aba7
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/address-matches/route.ts
@@ -0,0 +1,22 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getServerSession } from "next-auth";
+
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { getFlaggedAddresses } from "@/lib/bulkUpload/addressMatches";
+
+// Read-only: the combiner rows address2uprn could not confidently match
+// (unmatched / ambiguous_duplicate / invalid_postcode), joined with any saved
+// correction. Drives the pre-finalise "Addresses" review tab (ADR-0057); the
+// Finalise gate blocks until every flagged row is resolved.
+export async function GET(
+ _request: NextRequest,
+ { params }: { params: Promise<{ portfolioId: string; uploadId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
+
+ const { uploadId } = await params;
+ const flagged = await getFlaggedAddresses(uploadId);
+ const unresolved = flagged.filter((f) => !f.resolved).length;
+ return NextResponse.json({ flagged, unresolved }, { status: 200 });
+}
diff --git a/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/finalize/route.ts b/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/finalize/route.ts
index f326c65c..c5ecc423 100644
--- a/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/finalize/route.ts
+++ b/src/app/api/portfolio/[portfolioId]/bulk-uploads/[uploadId]/finalize/route.ts
@@ -35,6 +35,14 @@ export async function POST(
return NextResponse.json({ error: "Combiner not finished" }, { status: 409 });
case "missing_task":
return NextResponse.json({ error: "Upload has no task to finalise" }, { status: 409 });
+ case "unresolved_addresses":
+ return NextResponse.json(
+ {
+ error: `${result.count} address${result.count === 1 ? "" : "es"} still need a UPRN. Resolve them on the Addresses tab before finalising.`,
+ unresolvedAddresses: result.count,
+ },
+ { status: 409 },
+ );
case "wrong_state":
return NextResponse.json(
{ error: `Upload not ready to finalize (state: ${result.current})` },
diff --git a/src/app/api/portfolio/[portfolioId]/modelling-runs/preview/route.ts b/src/app/api/portfolio/[portfolioId]/modelling-runs/preview/route.ts
index 4817d91c..fd5af586 100644
--- a/src/app/api/portfolio/[portfolioId]/modelling-runs/preview/route.ts
+++ b/src/app/api/portfolio/[portfolioId]/modelling-runs/preview/route.ts
@@ -12,6 +12,7 @@ const bodySchema = z.object({
postcodes: z.array(z.string()).optional(),
propertyTypes: z.array(z.string()).optional(),
builtForms: z.array(z.string()).optional(),
+ tagIds: z.array(z.union([z.string(), z.number()])).optional(),
})
.default({}),
});
diff --git a/src/app/api/portfolio/[portfolioId]/modelling-runs/route.ts b/src/app/api/portfolio/[portfolioId]/modelling-runs/route.ts
index b62f8078..9b4af346 100644
--- a/src/app/api/portfolio/[portfolioId]/modelling-runs/route.ts
+++ b/src/app/api/portfolio/[portfolioId]/modelling-runs/route.ts
@@ -12,6 +12,7 @@ const filtersSchema = z.object({
postcodes: z.array(z.string()).optional(),
propertyTypes: z.array(z.string()).optional(),
builtForms: z.array(z.string()).optional(),
+ tagIds: z.array(z.union([z.string(), z.number()])).optional(),
});
const bodySchema = z.object({
@@ -51,6 +52,21 @@ export async function POST(
if (!normalised.ok) {
return NextResponse.json({ error: normalised.error }, { status: 400 });
}
+ // Defence-in-depth: the distributor can't resolve `tag_ids` yet (backend ask
+ // in docs/backend-asks/tag-ids-run-filter.md), so a tagged run would model the
+ // unscoped superset while preview counted the tag subset — the exact
+ // preview≠run divergence ADR-0008 forbids. Reject here so the block isn't
+ // UI-only (the RunModellingClient guard is just the friendly first line).
+ // Remove once the distributor lands `tag_ids`.
+ if (normalised.filters.tagIds?.length) {
+ return NextResponse.json(
+ {
+ error:
+ "Running scenarios over tags isn't available yet — the modelling engine can't scope by tag. Remove the tag filter to run.",
+ },
+ { status: 400 },
+ );
+ }
try {
const outcome = await triggerModellingRun({
diff --git a/src/app/api/portfolio/[portfolioId]/properties/[propertyId]/route.ts b/src/app/api/portfolio/[portfolioId]/properties/[propertyId]/route.ts
new file mode 100644
index 00000000..16b3e28d
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/properties/[propertyId]/route.ts
@@ -0,0 +1,90 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getServerSession } from "next-auth";
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { z } from "zod";
+import { db } from "@/app/db/db";
+import { property } from "@/app/db/schema/property";
+import { and, eq } from "drizzle-orm";
+
+// Assign a chosen Ordnance Survey address (from the postcode search) to an
+// existing property: writes the canonical uprn/address/postcode and keeps what
+// the user typed as the user-inputted fallback. Keyed by (property, portfolio)
+// so a caller can only touch a property in a portfolio they addressed. The
+// candidate is guaranteed residential + UPRN-bearing by the picker UI.
+const patchSchema = z.object({
+ uprn: z.string().regex(/^\d+$/, "UPRN must be numeric"),
+ address: z.string().trim().min(1, "Address is required"),
+ postcode: z.string().trim().min(1, "Postcode is required"),
+ // What the user typed in the edit fields — kept as the raw fallback, mirroring
+ // how the bulk finaliser stores user_inputted_* alongside the matched values.
+ userInputtedAddress: z.string().trim().optional(),
+ userInputtedPostcode: z.string().trim().optional(),
+});
+
+function isUniqueViolation(err: unknown): boolean {
+ const code = (err as { code?: string })?.code;
+ const message = (err as { message?: string })?.message ?? "";
+ return code === "23505" || message.includes("uq_property_portfolio_uprn");
+}
+
+export async function PATCH(
+ request: NextRequest,
+ props: { params: Promise<{ portfolioId: string; propertyId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session?.user?.email) {
+ return NextResponse.json({ error: "Unauthorised" }, { status: 401 });
+ }
+
+ const { portfolioId, propertyId } = await props.params;
+ if (!/^\d+$/.test(portfolioId) || !/^\d+$/.test(propertyId)) {
+ return NextResponse.json({ error: "Invalid id" }, { status: 400 });
+ }
+
+ const parsed = patchSchema.safeParse(await request.json().catch(() => null));
+ if (!parsed.success) {
+ return NextResponse.json(
+ { error: parsed.error.issues[0]?.message ?? "Invalid request" },
+ { status: 400 },
+ );
+ }
+ const { uprn, address, postcode, userInputtedAddress, userInputtedPostcode } =
+ parsed.data;
+
+ try {
+ const updated = await db
+ .update(property)
+ .set({
+ uprn: BigInt(uprn),
+ address,
+ postcode,
+ ...(userInputtedAddress !== undefined ? { userInputtedAddress } : {}),
+ ...(userInputtedPostcode !== undefined ? { userInputtedPostcode } : {}),
+ updatedAt: new Date(),
+ })
+ .where(
+ and(
+ eq(property.id, BigInt(propertyId)),
+ eq(property.portfolioId, BigInt(portfolioId)),
+ ),
+ )
+ .returning({ id: property.id });
+
+ if (updated.length === 0) {
+ return NextResponse.json({ error: "Property not found" }, { status: 404 });
+ }
+ return NextResponse.json({ ok: true });
+ } catch (err) {
+ if (isUniqueViolation(err)) {
+ return NextResponse.json(
+ {
+ error:
+ "That UPRN is already assigned to another property in this portfolio.",
+ },
+ { status: 409 },
+ );
+ }
+ console.error("PATCH /properties/[propertyId] error:", err);
+ return NextResponse.json({ error: "Internal server error" }, { status: 500 });
+ }
+}
diff --git a/src/app/api/portfolio/[portfolioId]/scenarios/route.ts b/src/app/api/portfolio/[portfolioId]/scenarios/route.ts
index a2065311..98539171 100644
--- a/src/app/api/portfolio/[portfolioId]/scenarios/route.ts
+++ b/src/app/api/portfolio/[portfolioId]/scenarios/route.ts
@@ -29,6 +29,7 @@ export async function POST(
exclusions: Array.isArray(b.exclusions)
? b.exclusions.filter((k): k is string => typeof k === "string")
: [],
+ fabricFirst: b.fabricFirst === true,
});
if (!result.ok) {
diff --git a/src/app/api/portfolio/[portfolioId]/tags/[tagId]/assignments/route.ts b/src/app/api/portfolio/[portfolioId]/tags/[tagId]/assignments/route.ts
new file mode 100644
index 00000000..64db0dba
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/tags/[tagId]/assignments/route.ts
@@ -0,0 +1,181 @@
+import { db } from "@/app/db/db";
+import { NextRequest, NextResponse } from "next/server";
+import { portfolioTag, propertyTag } from "@/app/db/schema/tags";
+import { property } from "@/app/db/schema/property";
+import { and, eq, inArray } from "drizzle-orm";
+import { z } from "zod";
+import { getServerSession } from "next-auth";
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { canWriteTags, getPortfolioRole } from "@/lib/tags/server";
+import { MAX_BULK_TAG_ROWS } from "@/lib/tags/bulkAssign";
+import { getFilteredPropertyIds } from "@/app/portfolio/[slug]/utils";
+import type { FilterGroups } from "@/app/utils/propertyFilters";
+
+type Params = { params: Promise<{ portfolioId: string; tagId: string }> };
+
+/** Batch size for membership writes — keeps a whole-portfolio op under the bind-param cap. */
+const CHUNK = 5000;
+
+const bodySchema = z.discriminatedUnion("mode", [
+ z.object({
+ mode: z.literal("properties"),
+ action: z.enum(["add", "remove"]),
+ propertyIds: z.array(z.string()).min(1),
+ }),
+ z.object({
+ mode: z.literal("filter"),
+ action: z.enum(["add", "remove"]),
+ // The property-table filter groups; resolved to ids server-side so the whole
+ // matching set is tagged, not just the visible page (ADR-0013).
+ filterGroups: z.array(z.unknown()),
+ }),
+ z.object({
+ mode: z.literal("identifiers"),
+ key: z.enum(["landlord_property_id", "uprn"]),
+ identifiers: z.array(z.string()).min(1).max(MAX_BULK_TAG_ROWS),
+ }),
+]);
+
+/**
+ * POST — add/remove Property memberships for one Tag (ADR-0013). `properties`
+ * mode takes explicit ids (the inline popover + row multi-select); `identifiers`
+ * mode matches a Bulk tag assignment upload's landlord ids / UPRNs to Properties
+ * and returns a match summary. All writes are idempotent.
+ */
+export async function POST(req: NextRequest, props: Params) {
+ const session = await getServerSession(AuthOptions);
+ const { portfolioId, tagId } = await props.params;
+ if (!session?.user?.email) {
+ return NextResponse.json({ error: "Unauthorised" }, { status: 401 });
+ }
+ if (!/^\d+$/.test(portfolioId) || !/^\d+$/.test(tagId)) {
+ return NextResponse.json({ error: "Invalid id" }, { status: 400 });
+ }
+ const pId = BigInt(portfolioId);
+ const tId = BigInt(tagId);
+
+ const role = await getPortfolioRole(pId, session.user.email);
+ if (!canWriteTags(role)) {
+ return NextResponse.json({ error: "Forbidden" }, { status: 403 });
+ }
+
+ // The tag must belong to this portfolio (prevents cross-portfolio writes).
+ const tag = await db
+ .select({ id: portfolioTag.id })
+ .from(portfolioTag)
+ .where(and(eq(portfolioTag.id, tId), eq(portfolioTag.portfolioId, pId)))
+ .limit(1);
+ if (tag.length === 0) {
+ return NextResponse.json({ error: "Tag not found" }, { status: 404 });
+ }
+
+ let body: z.infer;
+ try {
+ body = bodySchema.parse(await req.json());
+ } catch {
+ return NextResponse.json({ error: "Invalid body" }, { status: 400 });
+ }
+
+ if (body.mode === "properties" || body.mode === "filter") {
+ let ids: bigint[];
+ if (body.mode === "properties") {
+ // Only ids that actually belong to this portfolio (guards spoofed ids).
+ const owned = await db
+ .select({ id: property.id })
+ .from(property)
+ .where(
+ and(
+ eq(property.portfolioId, pId),
+ inArray(
+ property.id,
+ body.propertyIds.map((id) => BigInt(id)),
+ ),
+ ),
+ );
+ ids = owned.map((o) => o.id);
+ } else {
+ // Resolve the current property-table filter to its whole matching set.
+ ids = await getFilteredPropertyIds(portfolioId, body.filterGroups as FilterGroups);
+ }
+ if (ids.length === 0) return NextResponse.json({ changed: 0 });
+
+ // Chunk so a whole-portfolio selection stays under Postgres' bind-param cap.
+ let changed = 0;
+ for (let i = 0; i < ids.length; i += CHUNK) {
+ const batch = ids.slice(i, i + CHUNK);
+ if (body.action === "add") {
+ const inserted = await db
+ .insert(propertyTag)
+ .values(batch.map((propertyId) => ({ propertyId, tagId: tId })))
+ .onConflictDoNothing()
+ .returning({ propertyId: propertyTag.propertyId });
+ changed += inserted.length;
+ } else {
+ const removed = await db
+ .delete(propertyTag)
+ .where(
+ and(eq(propertyTag.tagId, tId), inArray(propertyTag.propertyId, batch)),
+ )
+ .returning({ propertyId: propertyTag.propertyId });
+ changed += removed.length;
+ }
+ }
+ return NextResponse.json({ changed });
+ }
+
+ // identifiers mode — Bulk tag assignment (add only) with a match summary.
+ if (body.mode !== "identifiers") {
+ return NextResponse.json({ error: "Invalid body" }, { status: 400 });
+ }
+ // Capture the narrowed discriminant in a const — TS widens `let body` back to
+ // the full union inside the closures below (e.g. matches.map).
+ const key = body.key;
+ const wanted = [...new Set(body.identifiers.map((s) => s.trim()).filter(Boolean))];
+ const matches = await db
+ .select({
+ id: property.id,
+ landlordPropertyId: property.landlordPropertyId,
+ uprn: property.uprn,
+ })
+ .from(property)
+ .where(
+ and(
+ eq(property.portfolioId, pId),
+ key === "uprn"
+ ? inArray(
+ property.uprn,
+ wanted
+ .filter((v) => /^\d+$/.test(v))
+ .map((v) => BigInt(v)),
+ )
+ : inArray(property.landlordPropertyId, wanted),
+ ),
+ );
+
+ const matchedValues = new Set(
+ matches.map((m) =>
+ key === "uprn" ? String(m.uprn) : String(m.landlordPropertyId),
+ ),
+ );
+ const unmatched = wanted.filter((v) => !matchedValues.has(v));
+ const matchedPropertyIds = matches.map((m) => m.id);
+
+ let taggedCount = 0;
+ for (let i = 0; i < matchedPropertyIds.length; i += CHUNK) {
+ const batch = matchedPropertyIds.slice(i, i + CHUNK);
+ const inserted = await db
+ .insert(propertyTag)
+ .values(batch.map((propertyId) => ({ propertyId, tagId: tId })))
+ .onConflictDoNothing()
+ .returning({ propertyId: propertyTag.propertyId });
+ taggedCount += inserted.length;
+ }
+
+ return NextResponse.json({
+ matchedPropertyCount: matchedPropertyIds.length,
+ taggedCount,
+ alreadyTaggedCount: matchedPropertyIds.length - taggedCount,
+ unmatchedCount: unmatched.length,
+ unmatchedIdentifiers: unmatched.slice(0, 100),
+ });
+}
diff --git a/src/app/api/portfolio/[portfolioId]/tags/[tagId]/route.ts b/src/app/api/portfolio/[portfolioId]/tags/[tagId]/route.ts
new file mode 100644
index 00000000..e210fa4e
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/tags/[tagId]/route.ts
@@ -0,0 +1,113 @@
+import { db } from "@/app/db/db";
+import { NextRequest, NextResponse } from "next/server";
+import { portfolioTag } from "@/app/db/schema/tags";
+import { and, eq, ne } from "drizzle-orm";
+import { z } from "zod";
+import { getServerSession } from "next-auth";
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { validateTagDraft } from "@/lib/tags/model";
+import {
+ canWriteTags,
+ getPortfolioRole,
+ isUniqueViolation,
+} from "@/lib/tags/server";
+
+const editSchema = z.object({ name: z.string(), colour: z.string() });
+
+type Params = { params: Promise<{ portfolioId: string; tagId: string }> };
+
+async function authWrite(portfolioId: string, tagId: string, email: string | undefined) {
+ if (!email) return { error: "Unauthorised", status: 401 as const };
+ if (!/^\d+$/.test(portfolioId) || !/^\d+$/.test(tagId)) {
+ return { error: "Invalid id", status: 400 as const };
+ }
+ const role = await getPortfolioRole(BigInt(portfolioId), email);
+ if (!canWriteTags(role)) return { error: "Forbidden", status: 403 as const };
+ return { ok: true as const };
+}
+
+/** PATCH — rename / recolour a tag (write-gated). */
+export async function PATCH(req: NextRequest, props: Params) {
+ const session = await getServerSession(AuthOptions);
+ const { portfolioId, tagId } = await props.params;
+ const auth = await authWrite(portfolioId, tagId, session?.user?.email);
+ if ("error" in auth) {
+ return NextResponse.json({ error: auth.error }, { status: auth.status });
+ }
+ const pId = BigInt(portfolioId);
+ const tId = BigInt(tagId);
+
+ let body: z.infer;
+ try {
+ body = editSchema.parse(await req.json());
+ } catch {
+ return NextResponse.json({ error: "Invalid body" }, { status: 400 });
+ }
+
+ // Uniqueness is checked against the OTHER tags, so a tag may keep/recase its
+ // own name (ADR-0013).
+ const others = await db
+ .select({ name: portfolioTag.name })
+ .from(portfolioTag)
+ .where(and(eq(portfolioTag.portfolioId, pId), ne(portfolioTag.id, tId)));
+
+ const result = validateTagDraft(body, others.map((o) => o.name));
+ if (!result.ok) {
+ return NextResponse.json({ error: result.error }, { status: 400 });
+ }
+
+ // The `others` pre-check is racy — two concurrent renames to the same name
+ // both pass it — so the case-insensitive unique index is the real guard.
+ // Mirror POST: a unique violation is a clean 409, not an uncaught 500.
+ let updated;
+ try {
+ updated = await db
+ .update(portfolioTag)
+ .set({ name: result.tag.name, colour: result.tag.colour })
+ .where(and(eq(portfolioTag.id, tId), eq(portfolioTag.portfolioId, pId)))
+ .returning({ id: portfolioTag.id });
+ } catch (err) {
+ if (isUniqueViolation(err)) {
+ return NextResponse.json(
+ { error: "A tag with this name already exists" },
+ { status: 409 },
+ );
+ }
+ console.error("PATCH /tags update error:", err);
+ return NextResponse.json({ error: "Couldn't save the tag" }, { status: 500 });
+ }
+
+ if (updated.length === 0) {
+ return NextResponse.json({ error: "Tag not found" }, { status: 404 });
+ }
+ return NextResponse.json({
+ id: tId.toString(),
+ name: result.tag.name,
+ colour: result.tag.colour,
+ });
+}
+
+/** DELETE — remove a tag; memberships cascade (ADR-0013). */
+export async function DELETE(_req: NextRequest, props: Params) {
+ const session = await getServerSession(AuthOptions);
+ const { portfolioId, tagId } = await props.params;
+ const auth = await authWrite(portfolioId, tagId, session?.user?.email);
+ if ("error" in auth) {
+ return NextResponse.json({ error: auth.error }, { status: auth.status });
+ }
+
+ const deleted = await db
+ .delete(portfolioTag)
+ .where(
+ and(
+ eq(portfolioTag.id, BigInt(tagId)),
+ eq(portfolioTag.portfolioId, BigInt(portfolioId)),
+ ),
+ )
+ .returning({ id: portfolioTag.id });
+
+ if (deleted.length === 0) {
+ return NextResponse.json({ error: "Tag not found" }, { status: 404 });
+ }
+ return NextResponse.json({ success: true });
+}
diff --git a/src/app/api/portfolio/[portfolioId]/tags/route.ts b/src/app/api/portfolio/[portfolioId]/tags/route.ts
new file mode 100644
index 00000000..60d474e7
--- /dev/null
+++ b/src/app/api/portfolio/[portfolioId]/tags/route.ts
@@ -0,0 +1,135 @@
+import { db } from "@/app/db/db";
+import { NextRequest, NextResponse } from "next/server";
+import { portfolioTag, propertyTag } from "@/app/db/schema/tags";
+import { eq, sql } from "drizzle-orm";
+import { z } from "zod";
+import { getServerSession } from "next-auth";
+import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
+import { validateTagDraft } from "@/lib/tags/model";
+import {
+ canReadTags,
+ canWriteTags,
+ getPortfolioRole,
+ isUniqueViolation,
+} from "@/lib/tags/server";
+
+const createSchema = z.object({
+ name: z.string(),
+ colour: z.string(),
+});
+
+/** GET — the portfolio's tags with their property counts (ADR-0013). */
+export async function GET(
+ _req: NextRequest,
+ props: { params: Promise<{ portfolioId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session?.user?.email) {
+ return NextResponse.json({ error: "Unauthorised" }, { status: 401 });
+ }
+ const { portfolioId } = await props.params;
+ if (!/^\d+$/.test(portfolioId)) {
+ return NextResponse.json({ error: "Invalid portfolio" }, { status: 400 });
+ }
+ const pId = BigInt(portfolioId);
+
+ const role = await getPortfolioRole(pId, session.user.email);
+ if (!canReadTags(role)) {
+ return NextResponse.json({ error: "Forbidden" }, { status: 403 });
+ }
+
+ const rows = await db
+ .select({
+ id: portfolioTag.id,
+ name: portfolioTag.name,
+ colour: portfolioTag.colour,
+ propertyCount: sql`count(${propertyTag.propertyId})::int`,
+ })
+ .from(portfolioTag)
+ .leftJoin(propertyTag, eq(propertyTag.tagId, portfolioTag.id))
+ .where(eq(portfolioTag.portfolioId, pId))
+ .groupBy(portfolioTag.id)
+ .orderBy(portfolioTag.name);
+
+ return NextResponse.json(
+ rows.map((r) => ({
+ id: r.id.toString(),
+ name: r.name,
+ colour: r.colour,
+ propertyCount: r.propertyCount,
+ })),
+ );
+}
+
+/** POST — create a tag (write-gated). */
+export async function POST(
+ req: NextRequest,
+ props: { params: Promise<{ portfolioId: string }> },
+) {
+ const session = await getServerSession(AuthOptions);
+ if (!session?.user?.email) {
+ return NextResponse.json({ error: "Unauthorised" }, { status: 401 });
+ }
+ const { portfolioId } = await props.params;
+ if (!/^\d+$/.test(portfolioId)) {
+ return NextResponse.json({ error: "Invalid portfolio" }, { status: 400 });
+ }
+ const pId = BigInt(portfolioId);
+
+ const role = await getPortfolioRole(pId, session.user.email);
+ if (!canWriteTags(role)) {
+ return NextResponse.json({ error: "Forbidden" }, { status: 403 });
+ }
+
+ let body: z.infer;
+ try {
+ body = createSchema.parse(await req.json());
+ } catch {
+ return NextResponse.json({ error: "Invalid body" }, { status: 400 });
+ }
+
+ const existing = await db
+ .select({ name: portfolioTag.name })
+ .from(portfolioTag)
+ .where(eq(portfolioTag.portfolioId, pId));
+
+ const result = validateTagDraft(body, existing.map((e) => e.name));
+ if (!result.ok) {
+ return NextResponse.json({ error: result.error }, { status: 400 });
+ }
+
+ try {
+ const [inserted] = await db
+ .insert(portfolioTag)
+ .values({
+ portfolioId: pId,
+ name: result.tag.name,
+ colour: result.tag.colour,
+ })
+ .returning({ id: portfolioTag.id });
+ return NextResponse.json(
+ {
+ id: inserted.id.toString(),
+ name: result.tag.name,
+ colour: result.tag.colour,
+ propertyCount: 0,
+ },
+ { status: 201 },
+ );
+ } catch (err) {
+ // Only the case-insensitive unique index racing a concurrent create is a
+ // 409; anything else (connection drop, other constraint) is a real failure
+ // that must not be masked as a duplicate-name.
+ if (isUniqueViolation(err)) {
+ return NextResponse.json(
+ { error: "A tag with this name already exists" },
+ { status: 409 },
+ );
+ }
+ console.error("POST /tags insert error:", err);
+ return NextResponse.json(
+ { error: "Couldn't create the tag" },
+ { status: 500 },
+ );
+ }
+}
diff --git a/src/app/api/properties/route.ts b/src/app/api/properties/route.ts
index bf0239a5..6726e8be 100644
--- a/src/app/api/properties/route.ts
+++ b/src/app/api/properties/route.ts
@@ -2,7 +2,10 @@ import { NextRequest, NextResponse } from "next/server";
import { getProperties, getPropertiesCount } from "@/app/portfolio/[slug]/utils";
import { FilterGroups } from "@/app/utils/propertyFilters";
-const DEFAULT_LIMIT = 1000;
+// The property list paginates at 7 rows/page and isn't scrolled through in bulk,
+// so a small initial page keeps the (join-heavy) query fast. Export fetches its
+// own larger batch on demand (see EXPORT_LIMIT in PropertyTable).
+const DEFAULT_LIMIT = 250;
export async function POST(req: NextRequest) {
const body = await req.json();
diff --git a/src/app/db/db.ts b/src/app/db/db.ts
index e973a875..9a336b18 100644
--- a/src/app/db/db.ts
+++ b/src/app/db/db.ts
@@ -16,6 +16,7 @@ import * as CrmSchema from "@/app/db/schema/crm/hubspot_deal_table";
import * as UploadedFilesSchema from "@/app/db/schema/uploaded_files";
import * as PortfolioOrgSchema from "@/app/db/schema/portfolio_organisation";
import * as BulkAddressUploadsSchema from "@/app/db/schema/bulk_address_uploads";
+import * as TagsSchema from "@/app/db/schema/tags";
export const pool = new Pool({
host: process.env.DB_HOST,
@@ -43,6 +44,7 @@ const schema = {
...UploadedFilesSchema,
...PortfolioOrgSchema,
...BulkAddressUploadsSchema,
+ ...TagsSchema,
};
export const db = drizzle(pool, {
diff --git a/src/app/db/migrations/0265_uprn_corrections.sql b/src/app/db/migrations/0265_uprn_corrections.sql
new file mode 100644
index 00000000..b81c825d
--- /dev/null
+++ b/src/app/db/migrations/0265_uprn_corrections.sql
@@ -0,0 +1,15 @@
+CREATE TABLE "bulk_upload_uprn_corrections" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "upload_id" uuid NOT NULL,
+ "source_row_id" text NOT NULL,
+ "uprn" text,
+ "address" text,
+ "postcode" text,
+ "marked_no_uprn" boolean DEFAULT false NOT NULL,
+ "user_id" text,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "bulk_upload_uprn_corrections_upload_row_unique" UNIQUE("upload_id","source_row_id")
+);
+--> statement-breakpoint
+ALTER TABLE "bulk_upload_uprn_corrections" ADD CONSTRAINT "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk" FOREIGN KEY ("upload_id") REFERENCES "public"."bulk_address_uploads"("id") ON DELETE cascade ON UPDATE no action;
\ No newline at end of file
diff --git a/src/app/db/migrations/0266_hesitant_bromley.sql b/src/app/db/migrations/0266_hesitant_bromley.sql
new file mode 100644
index 00000000..3f6463d9
--- /dev/null
+++ b/src/app/db/migrations/0266_hesitant_bromley.sql
@@ -0,0 +1,21 @@
+-- Covering partial index for the reporting "where the money goes" aggregate.
+-- The query joins the latest plan per property to its recommendations ON
+-- plan_id, filters to default = true AND already_installed = false, and sums
+-- estimated_cost / counts property_id per measure_type. The plain
+-- idx_recommendation_plan_id only locates the rows; the aggregate then
+-- heap-fetches every recommendation to apply the filter and read these
+-- columns, which times out on large portfolios (e.g. 434). Carrying
+-- measure_type, property_id and estimated_cost as key columns makes the whole
+-- aggregate index-only.
+--
+-- OPS: `recommendation` is large, so build this CONCURRENTLY out-of-band on
+-- prod BEFORE this migration runs, so the migration no-ops there (matches the
+-- 0258 idx_plan_recommendations_recommendation_id pattern). A plain
+-- CREATE INDEX here would lock writes on the table. Fresh environments build
+-- it inline via IF NOT EXISTS.
+--
+-- CREATE INDEX CONCURRENTLY IF NOT EXISTS "idx_recommendation_plan_default"
+-- ON "recommendation" USING btree ("plan_id","measure_type","property_id","estimated_cost")
+-- WHERE "default" = true AND "already_installed" = false;
+
+CREATE INDEX IF NOT EXISTS "idx_recommendation_plan_default" ON "recommendation" USING btree ("plan_id","measure_type","property_id","estimated_cost") WHERE "recommendation"."default" = true AND "recommendation"."already_installed" = false;
\ No newline at end of file
diff --git a/src/app/db/migrations/0267_add_hubspot_deal_planning_columns.sql b/src/app/db/migrations/0267_add_hubspot_deal_planning_columns.sql
new file mode 100644
index 00000000..e5731371
--- /dev/null
+++ b/src/app/db/migrations/0267_add_hubspot_deal_planning_columns.sql
@@ -0,0 +1,8 @@
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "design_constraints" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "planning_comments" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "planning_status" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "planning_suggested_approach" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "planning_authority" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "designated_area" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "article_4_pd_rights" text;--> statement-breakpoint
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "listed_building" text;
\ No newline at end of file
diff --git a/src/app/db/migrations/0268_free_magneto.sql b/src/app/db/migrations/0268_free_magneto.sql
new file mode 100644
index 00000000..dc7d0e9e
--- /dev/null
+++ b/src/app/db/migrations/0268_free_magneto.sql
@@ -0,0 +1 @@
+ALTER TABLE "scenario" ADD COLUMN "fabric_first" boolean DEFAULT false NOT NULL;
\ No newline at end of file
diff --git a/src/app/db/migrations/0269_lyrical_sway.sql b/src/app/db/migrations/0269_lyrical_sway.sql
new file mode 100644
index 00000000..d08480e6
--- /dev/null
+++ b/src/app/db/migrations/0269_lyrical_sway.sql
@@ -0,0 +1 @@
+CREATE INDEX "idx_plan_property_default_latest" ON "plan" USING btree ("property_id","portfolio_id","created_at" DESC NULLS LAST) WHERE is_default = true;
\ No newline at end of file
diff --git a/src/app/db/migrations/0270_epc_main_heating_detail_epc_property_index.sql b/src/app/db/migrations/0270_epc_main_heating_detail_epc_property_index.sql
new file mode 100644
index 00000000..87fe0140
--- /dev/null
+++ b/src/app/db/migrations/0270_epc_main_heating_detail_epc_property_index.sql
@@ -0,0 +1 @@
+CREATE INDEX "ix_epc_main_heating_detail_epc_property" ON "epc_main_heating_detail" USING btree ("epc_property_id");
\ No newline at end of file
diff --git a/src/app/db/migrations/0271_portfolio_tag_and_property_tag.sql b/src/app/db/migrations/0271_portfolio_tag_and_property_tag.sql
new file mode 100644
index 00000000..494eac09
--- /dev/null
+++ b/src/app/db/migrations/0271_portfolio_tag_and_property_tag.sql
@@ -0,0 +1,21 @@
+CREATE TABLE "portfolio_tag" (
+ "id" bigserial PRIMARY KEY NOT NULL,
+ "portfolio_id" bigint NOT NULL,
+ "name" text NOT NULL,
+ "colour" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "property_tag" (
+ "property_id" bigint NOT NULL,
+ "tag_id" bigint NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "property_tag_property_id_tag_id_pk" PRIMARY KEY("property_id","tag_id")
+);
+--> statement-breakpoint
+ALTER TABLE "portfolio_tag" ADD CONSTRAINT "portfolio_tag_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "property_tag" ADD CONSTRAINT "property_tag_property_id_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "public"."property"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "property_tag" ADD CONSTRAINT "property_tag_tag_id_portfolio_tag_id_fk" FOREIGN KEY ("tag_id") REFERENCES "public"."portfolio_tag"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE UNIQUE INDEX "uq_portfolio_tag_portfolio_lower_name" ON "portfolio_tag" USING btree ("portfolio_id",lower("name"));--> statement-breakpoint
+CREATE INDEX "ix_property_tag_tag" ON "property_tag" USING btree ("tag_id");
\ No newline at end of file
diff --git a/src/app/db/migrations/0272_flashy_brood.sql b/src/app/db/migrations/0272_flashy_brood.sql
new file mode 100644
index 00000000..4452344c
--- /dev/null
+++ b/src/app/db/migrations/0272_flashy_brood.sql
@@ -0,0 +1 @@
+ALTER TABLE "hubspot_deal_data" ADD COLUMN "third_party_surveyor_identifier" text;
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0265_snapshot.json b/src/app/db/migrations/meta/0265_snapshot.json
new file mode 100644
index 00000000..f1a9de80
--- /dev/null
+++ b/src/app/db/migrations/meta/0265_snapshot.json
@@ -0,0 +1,12120 @@
+{
+ "id": "4e7ec875-1845-4c68-b138-bd959a442454",
+ "prevId": "e7d5041b-5e3d-4f12-af83-3c67c451e234",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0266_snapshot.json b/src/app/db/migrations/meta/0266_snapshot.json
new file mode 100644
index 00000000..4887eae0
--- /dev/null
+++ b/src/app/db/migrations/meta/0266_snapshot.json
@@ -0,0 +1,12154 @@
+{
+ "id": "c7cb32fb-d13a-48b0-92d3-0e3187b2a36c",
+ "prevId": "4e7ec875-1845-4c68-b138-bd959a442454",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0267_snapshot.json b/src/app/db/migrations/meta/0267_snapshot.json
new file mode 100644
index 00000000..abe08854
--- /dev/null
+++ b/src/app/db/migrations/meta/0267_snapshot.json
@@ -0,0 +1,12202 @@
+{
+ "id": "e28c8709-1c4a-4276-8e8b-3a362321f901",
+ "prevId": "c7cb32fb-d13a-48b0-92d3-0e3187b2a36c",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_constraints": {
+ "name": "design_constraints",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_comments": {
+ "name": "planning_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_status": {
+ "name": "planning_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_suggested_approach": {
+ "name": "planning_suggested_approach",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_authority": {
+ "name": "planning_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designated_area": {
+ "name": "designated_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "article_4_pd_rights": {
+ "name": "article_4_pd_rights",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listed_building": {
+ "name": "listed_building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0268_snapshot.json b/src/app/db/migrations/meta/0268_snapshot.json
new file mode 100644
index 00000000..531f87b6
--- /dev/null
+++ b/src/app/db/migrations/meta/0268_snapshot.json
@@ -0,0 +1,12209 @@
+{
+ "id": "2c6ede49-5c77-4632-a78e-48436e11ef49",
+ "prevId": "e28c8709-1c4a-4276-8e8b-3a362321f901",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_constraints": {
+ "name": "design_constraints",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_comments": {
+ "name": "planning_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_status": {
+ "name": "planning_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_suggested_approach": {
+ "name": "planning_suggested_approach",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_authority": {
+ "name": "planning_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designated_area": {
+ "name": "designated_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "article_4_pd_rights": {
+ "name": "article_4_pd_rights",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listed_building": {
+ "name": "listed_building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fabric_first": {
+ "name": "fabric_first",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0269_snapshot.json b/src/app/db/migrations/meta/0269_snapshot.json
new file mode 100644
index 00000000..95db165f
--- /dev/null
+++ b/src/app/db/migrations/meta/0269_snapshot.json
@@ -0,0 +1,12237 @@
+{
+ "id": "e86b450d-6c85-4c75-b872-edf464d19415",
+ "prevId": "2c6ede49-5c77-4632-a78e-48436e11ef49",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_constraints": {
+ "name": "design_constraints",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_comments": {
+ "name": "planning_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_status": {
+ "name": "planning_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_suggested_approach": {
+ "name": "planning_suggested_approach",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_authority": {
+ "name": "planning_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designated_area": {
+ "name": "designated_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "article_4_pd_rights": {
+ "name": "article_4_pd_rights",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listed_building": {
+ "name": "listed_building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_property_default_latest": {
+ "name": "idx_plan_property_default_latest",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "is_default = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fabric_first": {
+ "name": "fabric_first",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0270_snapshot.json b/src/app/db/migrations/meta/0270_snapshot.json
new file mode 100644
index 00000000..83560668
--- /dev/null
+++ b/src/app/db/migrations/meta/0270_snapshot.json
@@ -0,0 +1,12253 @@
+{
+ "id": "eecb8dbb-4fbb-45db-9eed-51fbdd151a51",
+ "prevId": "e86b450d-6c85-4c75-b872-edf464d19415",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_constraints": {
+ "name": "design_constraints",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_comments": {
+ "name": "planning_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_status": {
+ "name": "planning_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_suggested_approach": {
+ "name": "planning_suggested_approach",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_authority": {
+ "name": "planning_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designated_area": {
+ "name": "designated_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "article_4_pd_rights": {
+ "name": "article_4_pd_rights",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listed_building": {
+ "name": "listed_building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_main_heating_detail_epc_property": {
+ "name": "ix_epc_main_heating_detail_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_property_default_latest": {
+ "name": "idx_plan_property_default_latest",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "is_default = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fabric_first": {
+ "name": "fabric_first",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0271_snapshot.json b/src/app/db/migrations/meta/0271_snapshot.json
new file mode 100644
index 00000000..d2a76958
--- /dev/null
+++ b/src/app/db/migrations/meta/0271_snapshot.json
@@ -0,0 +1,12423 @@
+{
+ "id": "160c9d62-6295-469a-92a4-1646bf1534fd",
+ "prevId": "eecb8dbb-4fbb-45db-9eed-51fbdd151a51",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_constraints": {
+ "name": "design_constraints",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_comments": {
+ "name": "planning_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_status": {
+ "name": "planning_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_suggested_approach": {
+ "name": "planning_suggested_approach",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_authority": {
+ "name": "planning_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designated_area": {
+ "name": "designated_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "article_4_pd_rights": {
+ "name": "article_4_pd_rights",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listed_building": {
+ "name": "listed_building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_main_heating_detail_epc_property": {
+ "name": "ix_epc_main_heating_detail_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_property_default_latest": {
+ "name": "idx_plan_property_default_latest",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "is_default = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fabric_first": {
+ "name": "fabric_first",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_tag": {
+ "name": "portfolio_tag",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "colour": {
+ "name": "colour",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_portfolio_tag_portfolio_lower_name": {
+ "name": "uq_portfolio_tag_portfolio_lower_name",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"name\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "portfolio_tag_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_tag_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_tag",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_tag": {
+ "name": "property_tag",
+ "schema": "",
+ "columns": {
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ix_property_tag_tag": {
+ "name": "ix_property_tag_tag",
+ "columns": [
+ {
+ "expression": "tag_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_tag_property_id_property_id_fk": {
+ "name": "property_tag_property_id_property_id_fk",
+ "tableFrom": "property_tag",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_tag_tag_id_portfolio_tag_id_fk": {
+ "name": "property_tag_tag_id_portfolio_tag_id_fk",
+ "tableFrom": "property_tag",
+ "tableTo": "portfolio_tag",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "property_tag_property_id_tag_id_pk": {
+ "name": "property_tag_property_id_tag_id_pk",
+ "columns": [
+ "property_id",
+ "tag_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/0272_snapshot.json b/src/app/db/migrations/meta/0272_snapshot.json
new file mode 100644
index 00000000..ed89d622
--- /dev/null
+++ b/src/app/db/migrations/meta/0272_snapshot.json
@@ -0,0 +1,12429 @@
+{
+ "id": "44eb87f5-2979-43c6-a96e-ba128b3d79a0",
+ "prevId": "160c9d62-6295-469a-92a4-1646bf1534fd",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.postcode_search": {
+ "name": "postcode_search",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_data": {
+ "name": "result_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_updated_at": {
+ "name": "last_updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "postcode_search_postcode_unique": {
+ "name": "postcode_search_postcode_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "postcode"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approval_events": {
+ "name": "deal_measure_approval_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_by": {
+ "name": "acted_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acted_at": {
+ "name": "acted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_events_deal_id": {
+ "name": "idx_deal_measure_events_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deal_measure_events_acted_at": {
+ "name": "idx_deal_measure_events_acted_at",
+ "columns": [
+ {
+ "expression": "acted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approval_events_acted_by_user_id_fk": {
+ "name": "deal_measure_approval_events_acted_by_user_id_fk",
+ "tableFrom": "deal_measure_approval_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deal_measure_approvals": {
+ "name": "deal_measure_approvals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_approved": {
+ "name": "is_approved",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deal_measure_approvals_deal_id": {
+ "name": "idx_deal_measure_approvals_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "deal_measure_approvals_approved_by_user_id_fk": {
+ "name": "deal_measure_approvals_approved_by_user_id_fk",
+ "tableFrom": "deal_measure_approvals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "approved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "uq_deal_measure": {
+ "name": "uq_deal_measure",
+ "nullsNotDistinct": false,
+ "columns": [
+ "hubspot_deal_id",
+ "measure_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_address_uploads": {
+ "name": "bulk_address_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_bucket": {
+ "name": "s3_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ready_for_processing'"
+ },
+ "source_headers": {
+ "name": "source_headers",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "column_mapping": {
+ "name": "column_mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_summary": {
+ "name": "multi_entry_summary",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_entry_ordering": {
+ "name": "multi_entry_ordering",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_ack": {
+ "name": "verify_ack",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "combined_output_s3_uri": {
+ "name": "combined_output_s3_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bulk_upload_uprn_corrections": {
+ "name": "bulk_upload_uprn_corrections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "upload_id": {
+ "name": "upload_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_row_id": {
+ "name": "source_row_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_no_uprn": {
+ "name": "marked_no_uprn",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk": {
+ "name": "bulk_upload_uprn_corrections_upload_id_bulk_address_uploads_id_fk",
+ "tableFrom": "bulk_upload_uprn_corrections",
+ "tableTo": "bulk_address_uploads",
+ "columnsFrom": [
+ "upload_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "bulk_upload_uprn_corrections_upload_row_unique": {
+ "name": "bulk_upload_uprn_corrections_upload_row_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "upload_id",
+ "source_row_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.aspect_condition": {
+ "name": "aspect_condition",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "element_id": {
+ "name": "element_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_type": {
+ "name": "aspect_type",
+ "type": "aspect_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "aspect_instance": {
+ "name": "aspect_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "install_date": {
+ "name": "install_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "renewal_year": {
+ "name": "renewal_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comments": {
+ "name": "comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "aspect_condition_element_id_element_id_fk": {
+ "name": "aspect_condition_element_id_element_id_fk",
+ "tableFrom": "aspect_condition",
+ "tableTo": "element",
+ "columnsFrom": [
+ "element_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.element": {
+ "name": "element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_instance": {
+ "name": "element_instance",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "element_survey_id_property_condition_survey_id_fk": {
+ "name": "element_survey_id_property_condition_survey_id_fk",
+ "tableFrom": "element",
+ "tableTo": "property_condition_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_condition_survey": {
+ "name": "property_condition_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "date": {
+ "name": "date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_company_data": {
+ "name": "hubspot_company_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_deal_data": {
+ "name": "hubspot_deal_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "deal_id": {
+ "name": "deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dealname": {
+ "name": "dealname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dealstage": {
+ "name": "dealstage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "company_id": {
+ "name": "company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_code": {
+ "name": "project_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listing_id": {
+ "name": "listing_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome_notes": {
+ "name": "outcome_notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_description": {
+ "name": "major_condition_issue_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_photos": {
+ "name": "major_condition_issue_photos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "major_condition_issue_evidence_s3_url": {
+ "name": "major_condition_issue_evidence_s3_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_status": {
+ "name": "coordination_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_status": {
+ "name": "design_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "booking_status": {
+ "name": "booking_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pashub_link": {
+ "name": "pashub_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sharepoint_link": {
+ "name": "sharepoint_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dampmould_growth": {
+ "name": "dampmould_growth",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pre_sap": {
+ "name": "pre_sap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator": {
+ "name": "coordinator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_completion_date": {
+ "name": "mtp_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mtp_re_model_completion_date": {
+ "name": "mtp_re_model_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ioe_v3_completion_date": {
+ "name": "ioe_v3_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "proposed_measures": {
+ "name": "proposed_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approved_package": {
+ "name": "approved_package",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designer": {
+ "name": "designer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_type": {
+ "name": "design_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_completion_date": {
+ "name": "design_completion_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actual_measures_installed": {
+ "name": "actual_measures_installed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer": {
+ "name": "installer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installer_handover": {
+ "name": "installer_handover",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_status": {
+ "name": "lodgement_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_lodgement_date": {
+ "name": "measures_lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expected_commencement_date": {
+ "name": "expected_commencement_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordination_comments": {
+ "name": "coordination_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "damp_mould_and_repairs_comments": {
+ "name": "damp_mould_and_repairs_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch": {
+ "name": "batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_description": {
+ "name": "batch_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "block_reference": {
+ "name": "block_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nonfunded_measures": {
+ "name": "nonfunded_measures",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_prn": {
+ "name": "epc_prn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_post_sap_score_dropdown": {
+ "name": "potential_post_sap_score_dropdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score": {
+ "name": "ei_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ei_score__potential_": {
+ "name": "ei_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score": {
+ "name": "epc_sap_score",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_sap_score__potential_": {
+ "name": "epc_sap_score__potential_",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_date": {
+ "name": "confirmed_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_survey_time": {
+ "name": "confirmed_survey_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surveyed_date": {
+ "name": "surveyed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measures_for_pibi_ordered": {
+ "name": "measures_for_pibi_ordered",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_order_date": {
+ "name": "pibi_order_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pibi_completed_date": {
+ "name": "pibi_completed_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_date": {
+ "name": "property_halted_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_halted_reason": {
+ "name": "property_halted_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "technical_approved_measures_for_install": {
+ "name": "technical_approved_measures_for_install",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_to_installer_for_pricing": {
+ "name": "sent_to_installer_for_pricing",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_required": {
+ "name": "domna_survey_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_type": {
+ "name": "domna_survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domna_survey_date": {
+ "name": "domna_survey_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "date_booking_made": {
+ "name": "date_booking_made",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_contact_date": {
+ "name": "last_contact_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_call": {
+ "name": "last_outbound_call",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_outbound_email": {
+ "name": "last_outbound_email",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_submission_date": {
+ "name": "last_submission_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_attempts": {
+ "name": "number_of_attempts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_booking_reference": {
+ "name": "client_booking_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "third_party_surveyor_identifier": {
+ "name": "third_party_surveyor_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "design_constraints": {
+ "name": "design_constraints",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_comments": {
+ "name": "planning_comments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_status": {
+ "name": "planning_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_suggested_approach": {
+ "name": "planning_suggested_approach",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "planning_authority": {
+ "name": "planning_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "designated_area": {
+ "name": "designated_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "article_4_pd_rights": {
+ "name": "article_4_pd_rights",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "listed_building": {
+ "name": "listed_building",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_projects_data": {
+ "name": "hubspot_projects_data",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "hubspot_projects_data_project_id_unique": {
+ "name": "hubspot_projects_data_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.hubspot_users": {
+ "name": "hubspot_users",
+ "schema": "",
+ "columns": {
+ "hubspot_owner_id": {
+ "name": "hubspot_owner_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_status_tracker": {
+ "name": "property_status_tracker",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_status_tracker_property_id_property_id_fk": {
+ "name": "property_status_tracker_property_id_property_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_status_tracker_portfolio_id_portfolio_id_fk": {
+ "name": "property_status_tracker_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_status_tracker",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessments": {
+ "name": "energy_assessments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency": {
+ "name": "current_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_energy_rating": {
+ "name": "current_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address1": {
+ "name": "address1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address2": {
+ "name": "address2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address3": {
+ "name": "address3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "posttown": {
+ "name": "posttown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "county": {
+ "name": "county",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency_label": {
+ "name": "constituency_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_light_count": {
+ "name": "low_energy_fixed_light_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_energy_eff": {
+ "name": "mainheat_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_env_eff": {
+ "name": "windows_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_energy_eff": {
+ "name": "lighting_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_potential": {
+ "name": "environment_impact_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatcont_description": {
+ "name": "mainheatcont_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_energy_eff": {
+ "name": "sheating_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "local_authority_label": {
+ "name": "local_authority_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "solar_water_heating_flag": {
+ "name": "solar_water_heating_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_description": {
+ "name": "floor_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_open_fireplaces": {
+ "name": "number_open_fireplaces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_description": {
+ "name": "windows_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_area": {
+ "name": "glazed_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mains_gas_flag": {
+ "name": "mains_gas_flag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emiss_curr_per_floor_area": {
+ "name": "co2_emiss_curr_per_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_storey_count": {
+ "name": "flat_storey_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_energy_eff": {
+ "name": "roof_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_description": {
+ "name": "roof_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_energy_eff": {
+ "name": "floor_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_habitable_rooms": {
+ "name": "number_habitable_rooms",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_env_eff": {
+ "name": "hot_water_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_energy_eff": {
+ "name": "mainheatc_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel": {
+ "name": "main_fuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_env_eff": {
+ "name": "lighting_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "windows_energy_eff": {
+ "name": "windows_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_env_eff": {
+ "name": "floor_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sheating_env_eff": {
+ "name": "sheating_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_description": {
+ "name": "lighting_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "roof_env_eff": {
+ "name": "roof_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_energy_eff": {
+ "name": "walls_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "photo_supply": {
+ "name": "photo_supply",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_env_eff": {
+ "name": "mainheat_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "multi_glaze_proportion": {
+ "name": "multi_glaze_proportion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_controls": {
+ "name": "main_heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_top_storey": {
+ "name": "flat_top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secondheat_description": {
+ "name": "secondheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_env_eff": {
+ "name": "walls_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extension_count": {
+ "name": "extension_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheatc_env_eff": {
+ "name": "mainheatc_env_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lmk_key": {
+ "name": "lmk_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine_count": {
+ "name": "wind_turbine_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_level": {
+ "name": "floor_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_efficiency": {
+ "name": "potential_energy_efficiency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "potential_energy_rating": {
+ "name": "potential_energy_rating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_energy_eff": {
+ "name": "hot_water_energy_eff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "low_energy_lighting": {
+ "name": "low_energy_lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "walls_description": {
+ "name": "walls_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hotwater_description": {
+ "name": "hotwater_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodgement_datetime": {
+ "name": "lodgement_datetime",
+ "type": "timestamp (6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mainheat_description": {
+ "name": "mainheat_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazed_type": {
+ "name": "glazed_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_location": {
+ "name": "file_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_company": {
+ "name": "surveyor_company",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_doors": {
+ "name": "number_of_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_insulated_doors": {
+ "name": "number_of_insulated_doors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_of_floors": {
+ "name": "number_of_floors",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulation_wall_area": {
+ "name": "insulation_wall_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter": {
+ "name": "heat_loss_perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length": {
+ "name": "party_wall_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "perimeter": {
+ "name": "perimeter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rooms_with_bath_and_or_shower": {
+ "name": "rooms_with_bath_and_or_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rooms_with_mixer_shower_no_bath": {
+ "name": "rooms_with_mixer_shower_no_bath",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_with_bath_and_mixer_shower": {
+ "name": "room_with_bath_and_mixer_shower",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draftproofed": {
+ "name": "percent_draftproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_type": {
+ "name": "cylinder_insulation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_insulation_thickness": {
+ "name": "cylinder_insulation_thickness",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cylinder_thermostat": {
+ "name": "cylinder_thermostat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_dwelling_ground_floor_area": {
+ "name": "main_dwelling_ground_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_windows": {
+ "name": "number_of_windows",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_area": {
+ "name": "windows_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_documents": {
+ "name": "energy_assessment_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_type": {
+ "name": "document_type",
+ "type": "document_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_location": {
+ "name": "document_location",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk": {
+ "name": "energy_assessment_documents_scenario_id_energy_assessment_scenarios_id_fk",
+ "tableFrom": "energy_assessment_documents",
+ "tableTo": "energy_assessment_scenarios",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.energy_assessment_scenarios": {
+ "name": "energy_assessment_scenarios",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "scenario_name": {
+ "name": "scenario_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_assessment_id": {
+ "name": "energy_assessment_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk": {
+ "name": "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk",
+ "tableFrom": "energy_assessment_scenarios",
+ "tableTo": "energy_assessments",
+ "columnsFrom": [
+ "energy_assessment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_store": {
+ "name": "epc_store",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api_created_at": {
+ "name": "epc_api_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_api": {
+ "name": "epc_api",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_created_at": {
+ "name": "epc_page_created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page": {
+ "name": "epc_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_page_rrn": {
+ "name": "epc_page_rrn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_store_uprn": {
+ "name": "uq_epc_store_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_from_surveyor": {
+ "name": "files_from_surveyor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_json_url": {
+ "name": "s3_json_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "files_from_surveyor_portfolio_id_portfolio_id_fk": {
+ "name": "files_from_surveyor_portfolio_id_portfolio_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_from_surveyor_property_id_property_id_fk": {
+ "name": "files_from_surveyor_property_id_property_id_fk",
+ "tableFrom": "files_from_surveyor",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package": {
+ "name": "funding_package",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scheme": {
+ "name": "scheme",
+ "type": "scheme",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "project_funding": {
+ "name": "project_funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_uplift": {
+ "name": "total_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_project_score": {
+ "name": "full_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_plan_id_plan_id_fk": {
+ "name": "funding_package_plan_id_plan_id_fk",
+ "tableFrom": "funding_package",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.funding_package_measures": {
+ "name": "funding_package_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "funding_package_id": {
+ "name": "funding_package_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure": {
+ "name": "measure",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "innovation_uplift": {
+ "name": "innovation_uplift",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "partial_project_score": {
+ "name": "partial_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uplift_project_score": {
+ "name": "uplift_project_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "funding_package_measures_funding_package_id_funding_package_id_fk": {
+ "name": "funding_package_measures_funding_package_id_funding_package_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "funding_package",
+ "columnsFrom": [
+ "funding_package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "funding_package_measures_material_id_material_id_fk": {
+ "name": "funding_package_measures_material_id_material_id_fk",
+ "tableFrom": "funding_package_measures",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.inspections": {
+ "name": "inspections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "archetype": {
+ "name": "archetype",
+ "type": "inspection_archetype",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archetype_2": {
+ "name": "archetype_2",
+ "type": "inspection_archetype_2",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "inspections_wall_construction",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation": {
+ "name": "insulation",
+ "type": "inspections_wall_insulation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulation_material": {
+ "name": "insulation_material",
+ "type": "inspections_insulation_material",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "borescoped": {
+ "name": "borescoped",
+ "type": "inspection_borescoped",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_orientation": {
+ "name": "roof_orientation",
+ "type": "inspections_roof_orientation",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tile_hung": {
+ "name": "tile_hung",
+ "type": "inspections_tile_hung",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rendered": {
+ "name": "rendered",
+ "type": "inspections_rendered",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cladding": {
+ "name": "cladding",
+ "type": "inspections_cladding",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_issues": {
+ "name": "access_issues",
+ "type": "inspections_access_issues",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor_name": {
+ "name": "surveyor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_at": {
+ "name": "uploaded_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "inspections_property_id_property_id_fk": {
+ "name": "inspections_property_id_property_id_fk",
+ "tableFrom": "inspections",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_built_form_type_overrides": {
+ "name": "landlord_built_form_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "built_form_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_built_form_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_built_form_type_overrides_portfolio_description_unique": {
+ "name": "landlord_built_form_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_construction_age_band_overrides": {
+ "name": "landlord_construction_age_band_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "construction_age_band",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_construction_age_band_overrides_portfolio_fk": {
+ "name": "landlord_construction_age_band_overrides_portfolio_fk",
+ "tableFrom": "landlord_construction_age_band_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_construction_age_band_portfolio_description_unique": {
+ "name": "landlord_construction_age_band_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_glazing_overrides": {
+ "name": "landlord_glazing_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "glazing",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_glazing_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_glazing_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_glazing_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_glazing_overrides_portfolio_description_unique": {
+ "name": "landlord_glazing_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_fuel_overrides": {
+ "name": "landlord_main_fuel_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_fuel",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_main_fuel_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_main_fuel_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_fuel_overrides_portfolio_description_unique": {
+ "name": "landlord_main_fuel_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_main_heating_system_overrides": {
+ "name": "landlord_main_heating_system_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "main_heating_system",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_main_heating_system_overrides_portfolio_fk": {
+ "name": "landlord_main_heating_system_overrides_portfolio_fk",
+ "tableFrom": "landlord_main_heating_system_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_main_heating_system_portfolio_description_unique": {
+ "name": "landlord_main_heating_system_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_property_type_overrides": {
+ "name": "landlord_property_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "property_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_property_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_property_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_property_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_property_type_overrides_portfolio_description_unique": {
+ "name": "landlord_property_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_roof_type_overrides": {
+ "name": "landlord_roof_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "roof_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_roof_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_roof_type_overrides_portfolio_description_unique": {
+ "name": "landlord_roof_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_wall_type_overrides": {
+ "name": "landlord_wall_type_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "wall_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_wall_type_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_wall_type_overrides_portfolio_description_unique": {
+ "name": "landlord_wall_type_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.landlord_water_heating_overrides": {
+ "name": "landlord_water_heating_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "water_heating",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "override_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "landlord_water_heating_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "landlord_water_heating_overrides_portfolio_description_unique": {
+ "name": "landlord_water_heating_overrides_portfolio_description_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "description"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door": {
+ "name": "magic_plan_door",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_mm": {
+ "name": "width_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_mm": {
+ "name": "height_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_door",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_door_ventilation": {
+ "name": "magic_plan_door_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_door_id": {
+ "name": "magic_plan_door_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "undercut_mm": {
+ "name": "undercut_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk",
+ "tableFrom": "magic_plan_door_ventilation",
+ "tableTo": "magic_plan_door",
+ "columnsFrom": [
+ "magic_plan_door_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_door_ventilation_magic_plan_door_id_unique": {
+ "name": "magic_plan_door_ventilation_magic_plan_door_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_door_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_floor": {
+ "name": "magic_plan_floor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_plan_id": {
+ "name": "magic_plan_plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk": {
+ "name": "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk",
+ "tableFrom": "magic_plan_floor",
+ "tableTo": "magic_plan_plan",
+ "columnsFrom": [
+ "magic_plan_plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_plan": {
+ "name": "magic_plan_plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "magic_plan_uid": {
+ "name": "magic_plan_uid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "magic_plan_plan_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "magic_plan_plan",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_plan_magic_plan_uid_unique": {
+ "name": "magic_plan_plan_magic_plan_uid_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_uid"
+ ]
+ },
+ "magic_plan_plan_uploaded_file_id_unique": {
+ "name": "magic_plan_plan_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_room": {
+ "name": "magic_plan_room",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_floor_id": {
+ "name": "magic_plan_floor_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "length_m": {
+ "name": "length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk": {
+ "name": "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk",
+ "tableFrom": "magic_plan_room",
+ "tableTo": "magic_plan_floor",
+ "columnsFrom": [
+ "magic_plan_floor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window": {
+ "name": "magic_plan_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_room_id": {
+ "name": "magic_plan_room_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width_m": {
+ "name": "width_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height_m": {
+ "name": "height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "area_m2": {
+ "name": "area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk": {
+ "name": "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk",
+ "tableFrom": "magic_plan_window",
+ "tableTo": "magic_plan_room",
+ "columnsFrom": [
+ "magic_plan_room_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.magic_plan_window_ventilation": {
+ "name": "magic_plan_window_ventilation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "magic_plan_window_id": {
+ "name": "magic_plan_window_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "opening_type": {
+ "name": "opening_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_openings": {
+ "name": "num_openings",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pct_openable": {
+ "name": "pct_openable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trickle_vent_area_mm2": {
+ "name": "trickle_vent_area_mm2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "num_trickle_vents": {
+ "name": "num_trickle_vents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk",
+ "tableFrom": "magic_plan_window_ventilation",
+ "tableTo": "magic_plan_window",
+ "columnsFrom": [
+ "magic_plan_window_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "magic_plan_window_ventilation_magic_plan_window_id_unique": {
+ "name": "magic_plan_window_ventilation_magic_plan_window_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "magic_plan_window_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.material": {
+ "name": "material",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depth": {
+ "name": "depth",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "depth_unit": {
+ "name": "depth_unit",
+ "type": "depth_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_unit": {
+ "name": "cost_unit",
+ "type": "cost_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_per_mm": {
+ "name": "r_value_per_mm",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r_value_unit": {
+ "name": "r_value_unit",
+ "type": "r_value_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity": {
+ "name": "thermal_conductivity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "type": "thermal_conductivity_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link": {
+ "name": "link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "prime_material_cost": {
+ "name": "prime_material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_cost": {
+ "name": "material_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_cost": {
+ "name": "labour_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_hours_per_unit": {
+ "name": "labour_hours_per_unit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plant_cost": {
+ "name": "plant_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_installer_quote": {
+ "name": "is_installer_quote",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "innovation_rate": {
+ "name": "innovation_rate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "size": {
+ "name": "size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "size_unit": {
+ "name": "size_unit",
+ "type": "size_unit",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "includes_scaffolding": {
+ "name": "includes_scaffolding",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "includes_battery": {
+ "name": "includes_battery",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "battery_size": {
+ "name": "battery_size",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_material_active": {
+ "name": "idx_material_active",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"material\".\"is_active\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organisation": {
+ "name": "organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "hubspot_company_id": {
+ "name": "hubspot_company_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.pibi_requests": {
+ "name": "pibi_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ordered_at": {
+ "name": "ordered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_pibi_requests_deal_id": {
+ "name": "idx_pibi_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_pibi_requests_portfolio_id": {
+ "name": "idx_pibi_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "pibi_requests_portfolio_id_portfolio_id_fk": {
+ "name": "pibi_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "pibi_requests_created_by_user_id_user_id_fk": {
+ "name": "pibi_requests_created_by_user_id_user_id_fk",
+ "tableFrom": "pibi_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_organisation": {
+ "name": "portfolio_organisation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organisation_id": {
+ "name": "organisation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_organisation_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_organisation_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolio_organisation_organisation_id_organisation_id_fk": {
+ "name": "portfolio_organisation_organisation_id_organisation_id_fk",
+ "tableFrom": "portfolio_organisation",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "organisation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_organisation_portfolio_id_organisation_id_unique": {
+ "name": "portfolio_organisation_portfolio_id_organisation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "organisation_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio": {
+ "name": "portfolio",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_capabilities": {
+ "name": "portfolio_capabilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capability": {
+ "name": "capability",
+ "type": "portfolio_capability",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolio_capabilities_user_id_user_id_fk": {
+ "name": "portfolio_capabilities_user_id_user_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolio_capabilities_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_capabilities_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_capabilities",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_capabilities_user_id_portfolio_id_capability_unique": {
+ "name": "portfolio_capabilities_user_id_portfolio_id_capability_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id",
+ "capability"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioInvitations": {
+ "name": "portfolioInvitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioInvitations_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioInvitations_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "portfolioInvitations_invited_by_user_id_user_id_fk": {
+ "name": "portfolioInvitations_invited_by_user_id_user_id_fk",
+ "tableFrom": "portfolioInvitations",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "portfolio_invitations_portfolio_email_unique": {
+ "name": "portfolio_invitations_portfolio_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "portfolio_id",
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolioUsers": {
+ "name": "portfolioUsers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "portfolioUsers_user_id_user_id_fk": {
+ "name": "portfolioUsers_user_id_user_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "portfolioUsers_portfolio_id_portfolio_id_fk": {
+ "name": "portfolioUsers_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolioUsers",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_overrides": {
+ "name": "property_overrides",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "building_part": {
+ "name": "building_part",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_component": {
+ "name": "override_component",
+ "type": "override_component",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "override_value": {
+ "name": "override_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "original_spreadsheet_description": {
+ "name": "original_spreadsheet_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_overrides_property_id_property_id_fk": {
+ "name": "property_overrides_property_id_property_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_overrides_portfolio_id_portfolio_id_fk": {
+ "name": "property_overrides_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_overrides",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_overrides_property_component_part_unique": {
+ "name": "property_overrides_property_component_part_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id",
+ "override_component",
+ "building_part"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_building_part": {
+ "name": "epc_building_part",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "construction_age_band": {
+ "name": "construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_construction": {
+ "name": "wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_insulation_type": {
+ "name": "wall_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wall_thickness_measured": {
+ "name": "wall_thickness_measured",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_construction": {
+ "name": "party_wall_construction",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_part_number": {
+ "name": "building_part_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_dry_lined": {
+ "name": "wall_dry_lined",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_thickness_mm": {
+ "name": "wall_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thickness": {
+ "name": "wall_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wall_insulation_thermal_conductivity": {
+ "name": "wall_insulation_thermal_conductivity",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_heat_loss": {
+ "name": "floor_heat_loss",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_thickness": {
+ "name": "floor_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flat_roof_insulation_thickness": {
+ "name": "flat_roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_type": {
+ "name": "floor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction_type": {
+ "name": "floor_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_insulation_type_str": {
+ "name": "floor_insulation_type_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_u_value_known": {
+ "name": "floor_u_value_known",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction": {
+ "name": "roof_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_location": {
+ "name": "roof_insulation_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_insulation_thickness": {
+ "name": "roof_insulation_thickness",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_construction_type": {
+ "name": "roof_construction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "curtain_wall_age": {
+ "name": "curtain_wall_age",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_floor_area": {
+ "name": "room_in_roof_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_in_roof_construction_age_band": {
+ "name": "room_in_roof_construction_age_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_area": {
+ "name": "alt_wall_1_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_dry_lined": {
+ "name": "alt_wall_1_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_construction": {
+ "name": "alt_wall_1_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_type": {
+ "name": "alt_wall_1_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_thickness_measured": {
+ "name": "alt_wall_1_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_insulation_thickness": {
+ "name": "alt_wall_1_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_1_is_sheltered": {
+ "name": "alt_wall_1_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_area": {
+ "name": "alt_wall_2_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_dry_lined": {
+ "name": "alt_wall_2_dry_lined",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_construction": {
+ "name": "alt_wall_2_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_type": {
+ "name": "alt_wall_2_insulation_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_thickness_measured": {
+ "name": "alt_wall_2_thickness_measured",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_insulation_thickness": {
+ "name": "alt_wall_2_insulation_thickness",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alt_wall_2_is_sheltered": {
+ "name": "alt_wall_2_is_sheltered",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_building_part_epc_property": {
+ "name": "ix_epc_building_part_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_building_part_epc_property_id_epc_property_id_fk": {
+ "name": "epc_building_part_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_building_part",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_energy_element": {
+ "name": "epc_energy_element",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "element_type": {
+ "name": "element_type",
+ "type": "energy_element_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_efficiency_rating": {
+ "name": "energy_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environmental_efficiency_rating": {
+ "name": "environmental_efficiency_rating",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ix_epc_energy_element_epc_property": {
+ "name": "ix_epc_energy_element_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_energy_element_epc_property_id_epc_property_id_fk": {
+ "name": "epc_energy_element_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_energy_element",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_flat_details": {
+ "name": "epc_flat_details",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "level": {
+ "name": "level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "top_storey": {
+ "name": "top_storey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flat_location": {
+ "name": "flat_location",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "storey_count": {
+ "name": "storey_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length_m": {
+ "name": "unheated_corridor_length_m",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_flat_details_epc_property_id_epc_property_id_fk": {
+ "name": "epc_flat_details_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_flat_details",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_flat_details_epc_property_id_unique": {
+ "name": "epc_flat_details_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_floor_dimension": {
+ "name": "epc_floor_dimension",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_building_part_id": {
+ "name": "epc_building_part_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor": {
+ "name": "floor",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "room_height_m": {
+ "name": "room_height_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "party_wall_length_m": {
+ "name": "party_wall_length_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_loss_perimeter_m": {
+ "name": "heat_loss_perimeter_m",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "floor_insulation": {
+ "name": "floor_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_construction": {
+ "name": "floor_construction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_exposed_floor": {
+ "name": "is_exposed_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_above_partially_heated_space": {
+ "name": "is_above_partially_heated_space",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "ix_epc_floor_dimension_building_part": {
+ "name": "ix_epc_floor_dimension_building_part",
+ "columns": [
+ {
+ "expression": "epc_building_part_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk": {
+ "name": "epc_floor_dimension_epc_building_part_id_epc_building_part_id_fk",
+ "tableFrom": "epc_floor_dimension",
+ "tableTo": "epc_building_part",
+ "columnsFrom": [
+ "epc_building_part_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_main_heating_detail": {
+ "name": "epc_main_heating_detail",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fghrs": {
+ "name": "has_fghrs",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_fuel_type": {
+ "name": "main_fuel_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heat_emitter_type": {
+ "name": "heat_emitter_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emitter_temperature": {
+ "name": "emitter_temperature",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "main_heating_control": {
+ "name": "main_heating_control",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fan_flue_present": {
+ "name": "fan_flue_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_flue_type": {
+ "name": "boiler_flue_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "boiler_ignition_type": {
+ "name": "boiler_ignition_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age": {
+ "name": "central_heating_pump_age",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "central_heating_pump_age_str": {
+ "name": "central_heating_pump_age_str",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_index_number": {
+ "name": "main_heating_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_main_heating_code": {
+ "name": "sap_main_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_number": {
+ "name": "main_heating_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_category": {
+ "name": "main_heating_category",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_fraction": {
+ "name": "main_heating_fraction",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "main_heating_data_source": {
+ "name": "main_heating_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "condensing": {
+ "name": "condensing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "weather_compensator": {
+ "name": "weather_compensator",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_boiler_fuel_type": {
+ "name": "community_heating_boiler_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "community_heating_chp_fraction": {
+ "name": "community_heating_chp_fraction",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ix_epc_main_heating_detail_epc_property": {
+ "name": "ix_epc_main_heating_detail_epc_property",
+ "columns": [
+ {
+ "expression": "epc_property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_main_heating_detail_epc_property_id_epc_property_id_fk": {
+ "name": "epc_main_heating_detail_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_main_heating_detail",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_photovoltaic_array": {
+ "name": "epc_photovoltaic_array",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_index": {
+ "name": "array_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_power": {
+ "name": "peak_power",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pitch": {
+ "name": "pitch",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "overshading": {
+ "name": "overshading",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_photovoltaic_array_epc_property_id_epc_property_id_fk": {
+ "name": "epc_photovoltaic_array_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_photovoltaic_array",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property": {
+ "name": "epc_property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_file_id": {
+ "name": "uploaded_file_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'lodged'"
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn_source": {
+ "name": "uprn_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_reference": {
+ "name": "report_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "report_type": {
+ "name": "report_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assessment_type": {
+ "name": "assessment_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_version": {
+ "name": "sap_version",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_type": {
+ "name": "schema_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schema_versions_original": {
+ "name": "schema_versions_original",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculation_software_version": {
+ "name": "calculation_software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_town": {
+ "name": "post_town",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "region_code": {
+ "name": "region_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dwelling_type": {
+ "name": "dwelling_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transaction_type": {
+ "name": "transaction_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inspection_date": {
+ "name": "inspection_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_date": {
+ "name": "completion_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "registration_date": {
+ "name": "registration_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area_m2": {
+ "name": "total_floor_area_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measurement_type": {
+ "name": "measurement_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_water_heating": {
+ "name": "solar_water_heating",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_hot_water_cylinder": {
+ "name": "has_hot_water_cylinder",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_fixed_air_conditioning": {
+ "name": "has_fixed_air_conditioning",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "has_conservatory": {
+ "name": "has_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_heated_separate_conservatory": {
+ "name": "has_heated_separate_conservatory",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_type": {
+ "name": "conservatory_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_floor_area_m2": {
+ "name": "conservatory_floor_area_m2",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_glazed_perimeter_m": {
+ "name": "conservatory_glazed_perimeter_m",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_double_glazed": {
+ "name": "conservatory_double_glazed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_thermally_separated": {
+ "name": "conservatory_thermally_separated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservatory_room_height_storeys": {
+ "name": "conservatory_room_height_storeys",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "door_count": {
+ "name": "door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wet_rooms_count": {
+ "name": "wet_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "extensions_count": {
+ "name": "extensions_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "heated_rooms_count": {
+ "name": "heated_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "open_chimneys_count": {
+ "name": "open_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "habitable_rooms_count": {
+ "name": "habitable_rooms_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "insulated_door_count": {
+ "name": "insulated_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cfl_fixed_lighting_bulbs_count": {
+ "name": "cfl_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "led_fixed_lighting_bulbs_count": {
+ "name": "led_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "incandescent_fixed_lighting_bulbs_count": {
+ "name": "incandescent_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "blocked_chimneys_count": {
+ "name": "blocked_chimneys_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draughtproofed_door_count": {
+ "name": "draughtproofed_door_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_average": {
+ "name": "energy_rating_average",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_bulbs_count": {
+ "name": "low_energy_fixed_lighting_bulbs_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fixed_lighting_outlets_count": {
+ "name": "fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "low_energy_fixed_lighting_outlets_count": {
+ "name": "low_energy_fixed_lighting_outlets_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "any_unheated_rooms": {
+ "name": "any_unheated_rooms",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hydro": {
+ "name": "hydro",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "photovoltaic_array": {
+ "name": "photovoltaic_array",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waste_water_heat_recovery": {
+ "name": "waste_water_heat_recovery",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test": {
+ "name": "pressure_test",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pressure_test_certificate_number": {
+ "name": "pressure_test_certificate_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "percent_draughtproofed": {
+ "name": "percent_draughtproofed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "insulated_door_u_value": {
+ "name": "insulated_door_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multiple_glazed_proportion": {
+ "name": "multiple_glazed_proportion",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_u_value": {
+ "name": "windows_transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_data_source": {
+ "name": "windows_transmission_data_source",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_transmission_solar_transmittance": {
+ "name": "windows_transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_gas_connection_available": {
+ "name": "energy_gas_connection_available",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_meter_type": {
+ "name": "energy_meter_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_battery_count": {
+ "name": "energy_pv_battery_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_count": {
+ "name": "energy_wind_turbines_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_gas_smart_meter_present": {
+ "name": "energy_gas_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_is_dwelling_export_capable": {
+ "name": "energy_is_dwelling_export_capable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_wind_turbines_terrain_type": {
+ "name": "energy_wind_turbines_terrain_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_electricity_smart_meter_present": {
+ "name": "energy_electricity_smart_meter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_pv_connection": {
+ "name": "energy_pv_connection",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_percent_roof_area": {
+ "name": "energy_pv_percent_roof_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_battery_capacity": {
+ "name": "energy_pv_battery_capacity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_hub_height": {
+ "name": "energy_wind_turbine_hub_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_wind_turbine_rotor_diameter": {
+ "name": "energy_wind_turbine_rotor_diameter",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_pv_diverter_present": {
+ "name": "energy_pv_diverter_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "heating_cylinder_size": {
+ "name": "heating_cylinder_size",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_code": {
+ "name": "heating_water_heating_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_water_heating_fuel": {
+ "name": "heating_water_heating_fuel",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_immersion_heating_type": {
+ "name": "heating_immersion_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_type": {
+ "name": "heating_cylinder_insulation_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_thermostat": {
+ "name": "heating_cylinder_thermostat",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_fuel_type": {
+ "name": "heating_secondary_fuel_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_secondary_heating_type": {
+ "name": "heating_secondary_heating_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_insulation_thickness_mm": {
+ "name": "heating_cylinder_insulation_thickness_mm",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cylinder_volume_measured_l": {
+ "name": "heating_cylinder_volume_measured_l",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_1": {
+ "name": "heating_wwhrs_index_number_1",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_wwhrs_index_number_2": {
+ "name": "heating_wwhrs_index_number_2",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_outlet_type": {
+ "name": "heating_shower_outlet_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_shower_wwhrs": {
+ "name": "heating_shower_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_type": {
+ "name": "ventilation_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_draught_lobby": {
+ "name": "ventilation_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_pressure_test": {
+ "name": "ventilation_pressure_test",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_open_flues_count": {
+ "name": "ventilation_open_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_closed_flues_count": {
+ "name": "ventilation_closed_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_boiler_flues_count": {
+ "name": "ventilation_boiler_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_other_flues_count": {
+ "name": "ventilation_other_flues_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_extract_fans_count": {
+ "name": "ventilation_extract_fans_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_passive_vents_count": {
+ "name": "ventilation_passive_vents_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_flueless_gas_fires_count": {
+ "name": "ventilation_flueless_gas_fires_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_in_pcdf_database": {
+ "name": "ventilation_in_pcdf_database",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation": {
+ "name": "mechanical_ventilation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_type": {
+ "name": "mechanical_vent_duct_type",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_placement": {
+ "name": "mechanical_vent_duct_placement",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation": {
+ "name": "mechanical_vent_duct_insulation",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_ventilation_index_number": {
+ "name": "mechanical_ventilation_index_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_measured_installation": {
+ "name": "mechanical_vent_measured_installation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mechanical_vent_duct_insulation_level": {
+ "name": "mechanical_vent_duct_insulation_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_stone_walls": {
+ "name": "addendum_stone_walls",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_system_build": {
+ "name": "addendum_system_build",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "addendum_numbers": {
+ "name": "addendum_numbers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths": {
+ "name": "heating_number_baths",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_number_baths_wwhrs": {
+ "name": "heating_number_baths_wwhrs",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_electric_shower_count": {
+ "name": "heating_electric_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_mixer_shower_count": {
+ "name": "heating_mixer_shower_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_present": {
+ "name": "ventilation_present",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "ventilation_sheltered_sides": {
+ "name": "ventilation_sheltered_sides",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_suspended_timber_floor": {
+ "name": "ventilation_has_suspended_timber_floor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_suspended_timber_floor_sealed": {
+ "name": "ventilation_suspended_timber_floor_sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_has_draught_lobby": {
+ "name": "ventilation_has_draught_lobby",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap4_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap4_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_air_permeability_ap50_m3_h_m2": {
+ "name": "ventilation_air_permeability_ap50_m3_h_m2",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation_mechanical_ventilation_kind": {
+ "name": "ventilation_mechanical_ventilation_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_epc_property_property_portfolio": {
+ "name": "uq_epc_property_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_epc_property_property_source": {
+ "name": "ix_epc_property_property_source",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "epc_property_property_id_property_id_fk": {
+ "name": "epc_property_property_id_property_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_portfolio_id_portfolio_id_fk": {
+ "name": "epc_property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "epc_property_uploaded_file_id_uploaded_files_id_fk": {
+ "name": "epc_property_uploaded_file_id_uploaded_files_id_fk",
+ "tableFrom": "epc_property",
+ "tableTo": "uploaded_files",
+ "columnsFrom": [
+ "uploaded_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_uploaded_file_id_unique": {
+ "name": "epc_property_uploaded_file_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "uploaded_file_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_property_energy_performance": {
+ "name": "epc_property_energy_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "energy_rating_current": {
+ "name": "energy_rating_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_current": {
+ "name": "energy_consumption_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_current": {
+ "name": "environmental_impact_current",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current": {
+ "name": "co2_emissions_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_current_per_floor_area": {
+ "name": "co2_emissions_current_per_floor_area",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_efficiency_band": {
+ "name": "current_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_rating_potential": {
+ "name": "energy_rating_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_potential": {
+ "name": "energy_consumption_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "environmental_impact_potential": {
+ "name": "environmental_impact_potential",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_potential": {
+ "name": "heating_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_potential": {
+ "name": "lighting_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_potential": {
+ "name": "hot_water_cost_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions_potential": {
+ "name": "co2_emissions_potential",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "potential_energy_efficiency_band": {
+ "name": "potential_energy_efficiency_band",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_property_energy_performance_epc_property_id_epc_property_id_fk": {
+ "name": "epc_property_energy_performance_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_property_energy_performance",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_property_energy_performance_epc_property_id_unique": {
+ "name": "epc_property_energy_performance_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_renewable_heat_incentive": {
+ "name": "epc_renewable_heat_incentive",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "impact_of_loft_insulation_kwh": {
+ "name": "impact_of_loft_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_cavity_insulation_kwh": {
+ "name": "impact_of_cavity_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "impact_of_solid_wall_insulation_kwh": {
+ "name": "impact_of_solid_wall_insulation_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_renewable_heat_incentive",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "epc_renewable_heat_incentive_epc_property_id_unique": {
+ "name": "epc_renewable_heat_incentive_epc_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "epc_property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.epc_window": {
+ "name": "epc_window",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epc_property_id": {
+ "name": "epc_property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_gap": {
+ "name": "glazing_gap",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "orientation": {
+ "name": "orientation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_type": {
+ "name": "window_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "glazing_type": {
+ "name": "glazing_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_width": {
+ "name": "window_width",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_height": {
+ "name": "window_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draught_proofed": {
+ "name": "draught_proofed",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_location": {
+ "name": "window_location",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_wall_type": {
+ "name": "window_wall_type",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permanent_shutters_present": {
+ "name": "permanent_shutters_present",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "frame_material": {
+ "name": "frame_material",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame_factor": {
+ "name": "frame_factor",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permanent_shutters_insulated": {
+ "name": "permanent_shutters_insulated",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_u_value": {
+ "name": "transmission_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_data_source": {
+ "name": "transmission_data_source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transmission_solar_transmittance": {
+ "name": "transmission_solar_transmittance",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "epc_window_epc_property_id_epc_property_id_fk": {
+ "name": "epc_window_epc_property_id_epc_property_id_fk",
+ "tableFrom": "epc_window",
+ "tableTo": "epc_property",
+ "columnsFrom": [
+ "epc_property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey": {
+ "name": "non_intrusive_survey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_date": {
+ "name": "survey_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surveyor": {
+ "name": "surveyor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.non_intrusive_survey_notes": {
+ "name": "non_intrusive_survey_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "survey_id": {
+ "name": "survey_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk": {
+ "name": "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk",
+ "tableFrom": "non_intrusive_survey_notes",
+ "tableTo": "non_intrusive_survey",
+ "columnsFrom": [
+ "survey_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property": {
+ "name": "property",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "creation_status": {
+ "name": "creation_status",
+ "type": "creation_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "certificate_number": {
+ "name": "certificate_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "building_reference_number": {
+ "name": "building_reference_number",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_address": {
+ "name": "user_inputted_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_inputted_postcode": {
+ "name": "user_inputted_postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lexiscore": {
+ "name": "lexiscore",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_pre_condition_report": {
+ "name": "has_pre_condition_report",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_recommendations": {
+ "name": "has_recommendations",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "property_type": {
+ "name": "property_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "built_form": {
+ "name": "built_form",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_authority": {
+ "name": "local_authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "constituency": {
+ "name": "constituency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_rooms": {
+ "name": "number_of_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "year_built": {
+ "name": "year_built",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tenure": {
+ "name": "tenure",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_epc_rating": {
+ "name": "current_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_sap_points": {
+ "name": "current_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_valuation": {
+ "name": "current_valuation",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_sap_point_adjustment": {
+ "name": "installed_measures_sap_point_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_sap_points_adjusted_for_installed_measures": {
+ "name": "is_sap_points_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "original_sap_points": {
+ "name": "original_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_sap_points": {
+ "name": "lodged_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_rating": {
+ "name": "lodged_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marked_for_deletion": {
+ "name": "marked_for_deletion",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "uq_property_portfolio_uprn": {
+ "name": "uq_property_portfolio_uprn",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"property\".\"uprn\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ix_property_portfolio": {
+ "name": "ix_property_portfolio",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_portfolio_id_portfolio_id_fk": {
+ "name": "property_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_baseline_performance": {
+ "name": "property_baseline_performance",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lodged_sap_score": {
+ "name": "lodged_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_epc_band": {
+ "name": "lodged_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_co2_emissions_t_per_yr": {
+ "name": "lodged_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "lodged_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "effective_sap_score": {
+ "name": "effective_sap_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_epc_band": {
+ "name": "effective_epc_band",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_co2_emissions_t_per_yr": {
+ "name": "effective_co2_emissions_t_per_yr",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effective_primary_energy_intensity_kwh_per_m2_yr": {
+ "name": "effective_primary_energy_intensity_kwh_per_m2_yr",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "type": "rebaseline_reason",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "space_heating_kwh": {
+ "name": "space_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "water_heating_kwh": {
+ "name": "water_heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fuel_rates_period": {
+ "name": "fuel_rates_period",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_kwh": {
+ "name": "heating_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_gbp": {
+ "name": "heating_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_kwh": {
+ "name": "hot_water_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_gbp": {
+ "name": "hot_water_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_kwh": {
+ "name": "lighting_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_gbp": {
+ "name": "lighting_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_kwh": {
+ "name": "appliances_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_gbp": {
+ "name": "appliances_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_kwh": {
+ "name": "cooking_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooking_cost_gbp": {
+ "name": "cooking_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_kwh": {
+ "name": "pumps_fans_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pumps_fans_cost_gbp": {
+ "name": "pumps_fans_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_kwh": {
+ "name": "cooling_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cooling_cost_gbp": {
+ "name": "cooling_cost_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "standing_charges_gbp": {
+ "name": "standing_charges_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seg_credit_gbp": {
+ "name": "seg_credit_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_annual_bill_gbp": {
+ "name": "total_annual_bill_gbp",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_baseline_performance_property_id_property_id_fk": {
+ "name": "property_baseline_performance_property_id_property_id_fk",
+ "tableFrom": "property_baseline_performance",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "property_baseline_performance_property_id_unique": {
+ "name": "property_baseline_performance_property_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "property_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_epc": {
+ "name": "property_details_epc",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_address": {
+ "name": "full_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodgement_date": {
+ "name": "lodgement_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_expired": {
+ "name": "is_expired",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_floor_area": {
+ "name": "total_floor_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls": {
+ "name": "walls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "walls_rating": {
+ "name": "walls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof": {
+ "name": "roof",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "roof_rating": {
+ "name": "roof_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor": {
+ "name": "floor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_rating": {
+ "name": "floor_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows": {
+ "name": "windows",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "windows_rating": {
+ "name": "windows_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating": {
+ "name": "heating",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_rating": {
+ "name": "heating_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls": {
+ "name": "heating_controls",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_controls_rating": {
+ "name": "heating_controls_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water": {
+ "name": "hot_water",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_rating": {
+ "name": "hot_water_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting": {
+ "name": "lighting",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_rating": {
+ "name": "lighting_rating",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mainfuel": {
+ "name": "mainfuel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ventilation": {
+ "name": "ventilation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_pv": {
+ "name": "solar_pv",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "solar_hot_water": {
+ "name": "solar_hot_water",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wind_turbine": {
+ "name": "wind_turbine",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "floor_height": {
+ "name": "floor_height",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_heated_rooms": {
+ "name": "number_heated_rooms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_loss_corridor": {
+ "name": "heat_loss_corridor",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "unheated_corridor_length": {
+ "name": "unheated_corridor_length",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_open_fireplaces": {
+ "name": "number_of_open_fireplaces",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_extensions": {
+ "name": "number_of_extensions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_storeys": {
+ "name": "number_of_storeys",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mains_gas": {
+ "name": "mains_gas",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_tariff": {
+ "name": "energy_tariff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_energy_consumption": {
+ "name": "primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_emissions": {
+ "name": "co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand": {
+ "name": "current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_energy_demand_heating_hotwater": {
+ "name": "current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated": {
+ "name": "estimated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_overwritten": {
+ "name": "sap_05_overwritten",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "sap_05_score": {
+ "name": "sap_05_score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_05_epc_rating": {
+ "name": "sap_05_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heating_cost_current": {
+ "name": "heating_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hot_water_cost_current": {
+ "name": "hot_water_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lighting_cost_current": {
+ "name": "lighting_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "appliances_cost_current": {
+ "name": "appliances_cost_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_standing_charge": {
+ "name": "gas_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "electricity_standing_charge": {
+ "name": "electricity_standing_charge",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_co2_emissions": {
+ "name": "original_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_primary_energy_consumption": {
+ "name": "original_primary_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand": {
+ "name": "original_current_energy_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_current_energy_demand_heating_hotwater": {
+ "name": "original_current_energy_demand_heating_hotwater",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_co2_adjustment": {
+ "name": "installed_measures_co2_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_energy_demand_adjustment": {
+ "name": "installed_measures_energy_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_total_energy_bill_adjustment": {
+ "name": "installed_measures_total_energy_bill_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_measures_heat_demand_adjustment": {
+ "name": "installed_measures_heat_demand_adjustment",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_epc_adjusted_for_installed_measures": {
+ "name": "is_epc_adjusted_for_installed_measures",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "lodged_co2_emissions": {
+ "name": "lodged_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lodged_heat_demand": {
+ "name": "lodged_heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "has_been_remodelled": {
+ "name": "has_been_remodelled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "environment_impact_current": {
+ "name": "environment_impact_current",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_epc_property_portfolio": {
+ "name": "uq_property_details_epc_property_portfolio",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_details_epc_property_id_property_id_fk": {
+ "name": "property_details_epc_property_id_property_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_details_epc_portfolio_id_portfolio_id_fk": {
+ "name": "property_details_epc_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_details_epc",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_meter": {
+ "name": "property_details_meter",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_supplier": {
+ "name": "energy_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gas_supplier": {
+ "name": "gas_supplier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_total": {
+ "name": "meter_reading_total",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_electricity": {
+ "name": "meter_reading_electricity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meter_reading_gas": {
+ "name": "meter_reading_gas",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_details_spatial": {
+ "name": "property_details_spatial",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "x_coordinate": {
+ "name": "x_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "y_coordinate": {
+ "name": "y_coordinate",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conservation_status": {
+ "name": "conservation_status",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_listed_building": {
+ "name": "is_listed_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_heritage_building": {
+ "name": "is_heritage_building",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "uq_property_details_spatial_uprn": {
+ "name": "uq_property_details_spatial_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_targets": {
+ "name": "property_targets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "epc": {
+ "name": "epc",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "property_targets_property_id_property_id_fk": {
+ "name": "property_targets_property_id_property_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_targets_portfolio_id_portfolio_id_fk": {
+ "name": "property_targets_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_targets",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.installed_measure": {
+ "name": "installed_measure",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "measure_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "carbon_savings": {
+ "name": "carbon_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bill_savings": {
+ "name": "bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand_savings": {
+ "name": "heat_demand_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "idx_installed_measure_uprn": {
+ "name": "idx_installed_measure_uprn",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_active": {
+ "name": "idx_installed_measure_uprn_active",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_measure_type": {
+ "name": "idx_installed_measure_measure_type",
+ "columns": [
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_installed_measure_uprn_measure": {
+ "name": "idx_installed_measure_uprn_measure",
+ "columns": [
+ {
+ "expression": "uprn",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"installed_measure\".\"is_active\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan": {
+ "name": "plan",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_id": {
+ "name": "scenario_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valuation_increase_lower_bound": {
+ "name": "valuation_increase_lower_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_upper_bound": {
+ "name": "valuation_increase_upper_bound",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase_average": {
+ "name": "valuation_increase_average",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_sap_points": {
+ "name": "post_sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_epc_rating": {
+ "name": "post_epc_rating",
+ "type": "epc",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_co2_emissions": {
+ "name": "post_co2_emissions",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_savings": {
+ "name": "co2_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_bill": {
+ "name": "post_energy_bill",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_savings": {
+ "name": "energy_bill_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "post_energy_consumption": {
+ "name": "post_energy_consumption",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_savings": {
+ "name": "energy_consumption_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_post_retrofit": {
+ "name": "valuation_post_retrofit",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_increase": {
+ "name": "valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_of_works": {
+ "name": "cost_of_works",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_type": {
+ "name": "plan_type",
+ "type": "plan_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_plan_portfolio_scenario": {
+ "name": "idx_plan_portfolio_scenario",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_latest_per_property": {
+ "name": "idx_plan_latest_per_property",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scenario_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_property_default_latest": {
+ "name": "idx_plan_property_default_latest",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "is_default = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_portfolio_id_portfolio_id_fk": {
+ "name": "plan_portfolio_id_portfolio_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_property_id_property_id_fk": {
+ "name": "plan_property_id_property_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_scenario_id_scenario_id_fk": {
+ "name": "plan_scenario_id_scenario_id_fk",
+ "tableFrom": "plan",
+ "tableTo": "scenario",
+ "columnsFrom": [
+ "scenario_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plan_recommendations": {
+ "name": "plan_recommendations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "idx_plan_recommendations_plan_id": {
+ "name": "idx_plan_recommendations_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_plan_rec": {
+ "name": "idx_plan_recommendations_plan_rec",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_plan_recommendations_recommendation_id": {
+ "name": "idx_plan_recommendations_recommendation_id",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plan_recommendations_plan_id_plan_id_fk": {
+ "name": "plan_recommendations_plan_id_plan_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "plan_recommendations_recommendation_id_recommendation_id_fk": {
+ "name": "plan_recommendations_recommendation_id_recommendation_id_fk",
+ "tableFrom": "plan_recommendations",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation": {
+ "name": "recommendation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity": {
+ "name": "material_quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_quantity_unit": {
+ "name": "material_quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "material_depth": {
+ "name": "material_depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_type": {
+ "name": "measure_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency_cost": {
+ "name": "contingency_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default": {
+ "name": "default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starting_u_value": {
+ "name": "starting_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_u_value": {
+ "name": "new_u_value",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sap_points": {
+ "name": "sap_points",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heat_demand": {
+ "name": "heat_demand",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kwh_savings": {
+ "name": "kwh_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rental_yield_increase": {
+ "name": "rental_yield_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed": {
+ "name": "already_installed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "recommendation_property_id_idx": {
+ "name": "recommendation_property_id_idx",
+ "columns": [
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_id": {
+ "name": "idx_recommendation_plan_id",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_defaults": {
+ "name": "idx_recommendation_active_defaults",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_active_id_property": {
+ "name": "idx_recommendation_active_id_property",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_plan_default": {
+ "name": "idx_recommendation_plan_default",
+ "columns": [
+ {
+ "expression": "plan_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "measure_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "property_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "estimated_cost",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"recommendation\".\"default\" = true AND \"recommendation\".\"already_installed\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_recommendation_material_id": {
+ "name": "idx_recommendation_material_id",
+ "columns": [
+ {
+ "expression": "material_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_property_id_property_id_fk": {
+ "name": "recommendation_property_id_property_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "recommendation_plan_id_plan_id_fk": {
+ "name": "recommendation_plan_id_plan_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "plan",
+ "columnsFrom": [
+ "plan_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_material_id_material_id_fk": {
+ "name": "recommendation_material_id_material_id_fk",
+ "tableFrom": "recommendation",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.recommendation_materials": {
+ "name": "recommendation_materials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "recommendation_id": {
+ "name": "recommendation_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "material_id": {
+ "name": "material_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "depth": {
+ "name": "depth",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quantity_unit": {
+ "name": "quantity_unit",
+ "type": "unit_quantity",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_cost": {
+ "name": "estimated_cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "recommendation_materials_recommendation_id_idx": {
+ "name": "recommendation_materials_recommendation_id_idx",
+ "columns": [
+ {
+ "expression": "recommendation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "recommendation_materials_recommendation_id_recommendation_id_fk": {
+ "name": "recommendation_materials_recommendation_id_recommendation_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "recommendation",
+ "columnsFrom": [
+ "recommendation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "recommendation_materials_material_id_material_id_fk": {
+ "name": "recommendation_materials_material_id_material_id_fk",
+ "tableFrom": "recommendation_materials",
+ "tableTo": "material",
+ "columnsFrom": [
+ "material_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scenario": {
+ "name": "scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "budget": {
+ "name": "budget",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "housing_type": {
+ "name": "housing_type",
+ "type": "housing_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "goal",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal_value": {
+ "name": "goal_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ashp_cop": {
+ "name": "ashp_cop",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 2.8
+ },
+ "trigger_file_path": {
+ "name": "trigger_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "already_installed_file_path": {
+ "name": "already_installed_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "patches_file_path": {
+ "name": "patches_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "non_invasive_recommendations_file_path": {
+ "name": "non_invasive_recommendations_file_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exclusions": {
+ "name": "exclusions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multi_plan": {
+ "name": "multi_plan",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "fabric_first": {
+ "name": "fabric_first",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contingency": {
+ "name": "contingency",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "funding": {
+ "name": "funding",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_work_hours": {
+ "name": "total_work_hours",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_savings": {
+ "name": "energy_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_equivalent_savings": {
+ "name": "co2_equivalent_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_cost_savings": {
+ "name": "energy_cost_savings",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "property_valuation_increase": {
+ "name": "property_valuation_increase",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "labour_days": {
+ "name": "labour_days",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_pre_retrofit": {
+ "name": "epc_breakdown_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "epc_breakdown_post_retrofit": {
+ "name": "epc_breakdown_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number_of_properties": {
+ "name": "number_of_properties",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "n_units_to_retrofit": {
+ "name": "n_units_to_retrofit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_pre_retrofit": {
+ "name": "co2_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "co2_per_unit_post_retrofit": {
+ "name": "co2_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_pre_retrofit": {
+ "name": "energy_bill_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_bill_per_unit_post_retrofit": {
+ "name": "energy_bill_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_pre_retrofit": {
+ "name": "energy_consumption_per_unit_pre_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "energy_consumption_per_unit_post_retrofit": {
+ "name": "energy_consumption_per_unit_post_retrofit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_improvement_per_unit": {
+ "name": "valuation_improvement_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_unit": {
+ "name": "cost_per_unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_co2_saved": {
+ "name": "cost_per_co2_saved",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_per_sap_point": {
+ "name": "cost_per_sap_point",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "valuation_return_on_investment": {
+ "name": "valuation_return_on_investment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "scenario_portfolio_id_portfolio_id_fk": {
+ "name": "scenario_portfolio_id_portfolio_id_fk",
+ "tableFrom": "scenario",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_removal_requests": {
+ "name": "property_removal_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'removal'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "reviewed_by": {
+ "name": "reviewed_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_batch": {
+ "name": "original_batch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_removal_requests_deal_id": {
+ "name": "idx_removal_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_removal_requests_portfolio_id": {
+ "name": "idx_removal_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_removal_requests_portfolio_id_portfolio_id_fk": {
+ "name": "property_removal_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_requested_by_user_id_fk": {
+ "name": "property_removal_requests_requested_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "property_removal_requests_reviewed_by_user_id_fk": {
+ "name": "property_removal_requests_reviewed_by_user_id_fk",
+ "tableFrom": "property_removal_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "reviewed_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar": {
+ "name": "solar",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "longitude": {
+ "name": "longitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "latitude": {
+ "name": "latitude",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "google_api_response": {
+ "name": "google_api_response",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.solar_scenario": {
+ "name": "solar_scenario",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "solar_id": {
+ "name": "solar_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scenario_type": {
+ "name": "scenario_type",
+ "type": "scenario_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number_panels": {
+ "name": "number_panels",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "array_kwhp": {
+ "name": "array_kwhp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_dc_kwh": {
+ "name": "lifetime_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "yearly_dc_kwh": {
+ "name": "yearly_dc_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lifetime_ac_kwh": {
+ "name": "lifetime_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "yearly_ac_kwh": {
+ "name": "yearly_ac_kwh",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_payback_years": {
+ "name": "expected_payback_years",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "panelled_roof_area": {
+ "name": "panelled_roof_area",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "solar_scenario_solar_id_solar_id_fk": {
+ "name": "solar_scenario_solar_id_solar_id_fk",
+ "tableFrom": "solar_scenario",
+ "tableTo": "solar",
+ "columnsFrom": [
+ "solar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.survey_requests": {
+ "name": "survey_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "survey_type": {
+ "name": "survey_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "fulfilled_at": {
+ "name": "fulfilled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_survey_requests_deal_id": {
+ "name": "idx_survey_requests_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_survey_requests_portfolio_id": {
+ "name": "idx_survey_requests_portfolio_id",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "survey_requests_portfolio_id_portfolio_id_fk": {
+ "name": "survey_requests_portfolio_id_portfolio_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "survey_requests_requested_by_user_id_fk": {
+ "name": "survey_requests_requested_by_user_id_fk",
+ "tableFrom": "survey_requests",
+ "tableTo": "user",
+ "columnsFrom": [
+ "requested_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.portfolio_tag": {
+ "name": "portfolio_tag",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "colour": {
+ "name": "colour",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "uq_portfolio_tag_portfolio_lower_name": {
+ "name": "uq_portfolio_tag_portfolio_lower_name",
+ "columns": [
+ {
+ "expression": "portfolio_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"name\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "portfolio_tag_portfolio_id_portfolio_id_fk": {
+ "name": "portfolio_tag_portfolio_id_portfolio_id_fk",
+ "tableFrom": "portfolio_tag",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.property_tag": {
+ "name": "property_tag",
+ "schema": "",
+ "columns": {
+ "property_id": {
+ "name": "property_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ix_property_tag_tag": {
+ "name": "ix_property_tag_tag",
+ "columns": [
+ {
+ "expression": "tag_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "property_tag_property_id_property_id_fk": {
+ "name": "property_tag_property_id_property_id_fk",
+ "tableFrom": "property_tag",
+ "tableTo": "property",
+ "columnsFrom": [
+ "property_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "property_tag_tag_id_portfolio_tag_id_fk": {
+ "name": "property_tag_tag_id_portfolio_tag_id_fk",
+ "tableFrom": "property_tag",
+ "tableTo": "portfolio_tag",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "property_tag_property_id_tag_id_pk": {
+ "name": "property_tag_property_id_tag_id_pk",
+ "columns": [
+ "property_id",
+ "tag_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sub_task": {
+ "name": "sub_task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outputs": {
+ "name": "outputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cloud_logs_url": {
+ "name": "cloud_logs_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sub_task_task_id_tasks_id_fk": {
+ "name": "sub_task_task_id_tasks_id_fk",
+ "tableFrom": "sub_task",
+ "tableTo": "tasks",
+ "columnsFrom": [
+ "task_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_source": {
+ "name": "task_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "job_started": {
+ "name": "job_started",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "job_completed": {
+ "name": "job_completed",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'In Progress'"
+ },
+ "service": {
+ "name": "service",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inputs": {
+ "name": "inputs",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "org_id": {
+ "name": "org_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_org_id_organisation_id_fk": {
+ "name": "team_org_id_organisation_id_fk",
+ "tableFrom": "team",
+ "tableTo": "organisation",
+ "columnsFrom": [
+ "org_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_members": {
+ "name": "team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_members_user_id_user_id_fk": {
+ "name": "team_members_user_id_user_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_members_team_id_team_id_fk": {
+ "name": "team_members_team_id_team_id_fk",
+ "tableFrom": "team_members",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_portfolio_permissions": {
+ "name": "team_portfolio_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_portfolio_permissions_team_id_team_id_fk": {
+ "name": "team_portfolio_permissions_team_id_team_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "team_portfolio_permissions_portfolio_id_portfolio_id_fk": {
+ "name": "team_portfolio_permissions_portfolio_id_portfolio_id_fk",
+ "tableFrom": "team_portfolio_permissions",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.uploaded_files": {
+ "name": "uploaded_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "s3_file_bucket": {
+ "name": "s3_file_bucket",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_file_key": {
+ "name": "s3_file_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_upload_timestamp": {
+ "name": "s3_upload_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "landlord_property_id": {
+ "name": "landlord_property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uprn": {
+ "name": "uprn",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hubspot_listing_id": {
+ "name": "hubspot_listing_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "file_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_source": {
+ "name": "file_source",
+ "type": "file_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "uploaded_files_uploaded_by_user_id_fk": {
+ "name": "uploaded_files_uploaded_by_user_id_fk",
+ "tableFrom": "uploaded_files",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_defined_deal_measures": {
+ "name": "user_defined_deal_measures",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "hubspot_deal_id": {
+ "name": "hubspot_deal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "measure_name": {
+ "name": "measure_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "user_defined_deal_measure_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "pushed_at": {
+ "name": "pushed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmed_in_hubspot_at": {
+ "name": "confirmed_in_hubspot_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "idx_user_defined_deal_measures_deal_id": {
+ "name": "idx_user_defined_deal_measures_deal_id",
+ "columns": [
+ {
+ "expression": "hubspot_deal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_user_defined_deal_measures_source": {
+ "name": "idx_user_defined_deal_measures_source",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_defined_deal_measures_created_by_user_id_user_id_fk": {
+ "name": "user_defined_deal_measures_created_by_user_id_user_id_fk",
+ "tableFrom": "user_defined_deal_measures",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_config": {
+ "name": "user_portfolio_config",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "portfolio_id": {
+ "name": "portfolio_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "starred_at": {
+ "name": "starred_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_config_folder": {
+ "name": "idx_user_portfolio_config_folder",
+ "columns": [
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_config_user_id_user_id_fk": {
+ "name": "user_portfolio_config_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_portfolio_id_portfolio_id_fk": {
+ "name": "user_portfolio_config_portfolio_id_portfolio_id_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "portfolio",
+ "columnsFrom": [
+ "portfolio_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_config_folder_owner_fk": {
+ "name": "user_portfolio_config_folder_owner_fk",
+ "tableFrom": "user_portfolio_config",
+ "tableTo": "user_portfolio_folders",
+ "columnsFrom": [
+ "folder_id",
+ "user_id"
+ ],
+ "columnsTo": [
+ "id",
+ "user_id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_config_user_portfolio_unique": {
+ "name": "user_portfolio_config_user_portfolio_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "portfolio_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_portfolio_folders": {
+ "name": "user_portfolio_folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_user_portfolio_folders_user_position": {
+ "name": "idx_user_portfolio_folders_user_position",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_portfolio_folders_user_id_user_id_fk": {
+ "name": "user_portfolio_folders_user_id_user_id_fk",
+ "tableFrom": "user_portfolio_folders",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_portfolio_folders_id_user_unique": {
+ "name": "user_portfolio_folders_id_user_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "name": "account_provider_providerAccountId_pk",
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.authRateLimits": {
+ "name": "authRateLimits",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "authRateLimits_scope_key_pk": {
+ "name": "authRateLimits_scope_key_pk",
+ "columns": [
+ "scope",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_id": {
+ "name": "oauth_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "oauth_provider": {
+ "name": "oauth_provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarded": {
+ "name": "onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_login": {
+ "name": "last_login",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_profiles": {
+ "name": "user_profiles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_type": {
+ "name": "user_type",
+ "type": "user_profiles_user_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_count": {
+ "name": "property_count",
+ "type": "user_profiles_property_count",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goals": {
+ "name": "goals",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referral_source": {
+ "name": "referral_source",
+ "type": "user_profiles_referral_source",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nrla_membership_id": {
+ "name": "nrla_membership_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_privacy": {
+ "name": "accepted_privacy",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "accepted_privacy_at": {
+ "name": "accepted_privacy_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "marketing_opt_in": {
+ "name": "marketing_opt_in",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "marketing_opt_in_at": {
+ "name": "marketing_opt_in_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp (6) with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_profiles_user_id_user_id_fk": {
+ "name": "user_profiles_user_id_user_id_fk",
+ "tableFrom": "user_profiles",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verificationToken": {
+ "name": "verificationToken",
+ "schema": "",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "code_hash": {
+ "name": "code_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "name": "verificationToken_identifier_token_pk",
+ "columns": [
+ "identifier",
+ "token"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.whlg": {
+ "name": "whlg",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "postcode": {
+ "name": "postcode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.aspect_type": {
+ "name": "aspect_type",
+ "schema": "public",
+ "values": [
+ "material",
+ "condition",
+ "type",
+ "area",
+ "configuration",
+ "presence",
+ "risk",
+ "severity",
+ "location",
+ "finish",
+ "insulation",
+ "pointing",
+ "spalling",
+ "lintels",
+ "cladding",
+ "category",
+ "quantity",
+ "adequacy",
+ "rating",
+ "strategy",
+ "extent",
+ "distribution",
+ "structure",
+ "covering",
+ "fire_rating",
+ "external_decoration",
+ "work_required",
+ "age_band",
+ "construction_type",
+ "classification",
+ "system"
+ ]
+ },
+ "public.element_type": {
+ "name": "element_type",
+ "schema": "public",
+ "values": [
+ "property",
+ "property_construction_type",
+ "property_classification",
+ "property_age_band",
+ "storey_count",
+ "floor_level",
+ "floor_level_front_door",
+ "accessible_housing_register",
+ "asbestos",
+ "quality_standard",
+ "ccu",
+ "passenger_lift",
+ "stairlift",
+ "disabled_hoist_tracking",
+ "disabled_facilities",
+ "steps_to_front_door",
+ "roof",
+ "pitched_roof_covering",
+ "flat_roof_covering",
+ "rainwater_goods",
+ "loft_insulation",
+ "porch_canopy",
+ "chimney",
+ "fascia",
+ "soffit",
+ "fascia_soffit_bargeboards",
+ "gutters",
+ "store_roof",
+ "garage_roof",
+ "garage_and_store_roof",
+ "external_wall",
+ "external_noise_insulation",
+ "primary_wall",
+ "secondary_wall",
+ "downpipes",
+ "external_decoration",
+ "cladding",
+ "spandrel_panels",
+ "garage_walls",
+ "party_wall_fire_break",
+ "external_brickwork_pointing",
+ "internal_downpipes_external_area",
+ "external_windows",
+ "communal_windows",
+ "secondary_glazing",
+ "store_windows",
+ "garage_windows",
+ "garage_and_store_windows",
+ "external_door",
+ "front_door",
+ "rear_door",
+ "store_door",
+ "garage_door",
+ "garage_and_store_door",
+ "communal_entrance_door",
+ "main_door",
+ "block_entrance_door",
+ "lintel",
+ "patio_french_door",
+ "door_entry_handset",
+ "paths_and_hardstandings",
+ "parking_areas",
+ "boundary_walls",
+ "front_fencing",
+ "rear_fencing",
+ "side_fencing",
+ "rear_gate",
+ "front_gate",
+ "gates",
+ "retaining_walls",
+ "private_balcony",
+ "balcony_balustrade",
+ "outbuildings",
+ "garage_structure",
+ "paving",
+ "roads",
+ "soil_and_vent",
+ "solar_thermals",
+ "drop_kerb",
+ "outbuilding_overhaul",
+ "external_structural_defects",
+ "access_ramp",
+ "kitchen",
+ "kitchen_space_layout",
+ "tenant_installed_kitchen",
+ "kitchen_extractor_fan",
+ "bathroom",
+ "secondary_bathroom",
+ "secondary_toilet",
+ "bathroom_extractor_fan",
+ "additional_wc_or_whb",
+ "bathroom_remaining_life_source",
+ "kitchen_remaining_life_source",
+ "central_heating",
+ "heating_boiler",
+ "heating_distribution",
+ "secondary_heating",
+ "hot_water_system",
+ "cold_water_storage",
+ "heating_system",
+ "boiler_fuel",
+ "water_heating",
+ "programmable_heating",
+ "community_heating",
+ "gas_available",
+ "heat_recovery_units",
+ "heating_improvements",
+ "electrical_wiring",
+ "consumer_unit",
+ "smoke_detection",
+ "heat_detection",
+ "carbon_monoxide_detection",
+ "fire_door_rating",
+ "fire_risk_assessment",
+ "internal_wiring",
+ "electrics",
+ "communal_heating",
+ "communal_boiler",
+ "communal_electrics",
+ "communal_fire_alarm",
+ "communal_emergency_lighting",
+ "communal_door_entry",
+ "communal_cctv",
+ "communal_bin_store",
+ "communal_bin_store_doors",
+ "communal_bin_store_walls",
+ "communal_bin_store_roof",
+ "communal_refuse_chute",
+ "communal_floor_covering",
+ "communal_kitchen",
+ "communal_bathroom",
+ "communal_toilets",
+ "communal_gates",
+ "communal_lift",
+ "communal_passenger_lift",
+ "communal_balcony_walkway",
+ "communal_entrance",
+ "communal_internal_decorations",
+ "communal_internal_floor",
+ "communal_walkways",
+ "communal_external_doors",
+ "communal_stairs",
+ "communal_aerial",
+ "communal_aov",
+ "communal_internal_doors",
+ "communal_lateral_mains",
+ "communal_lighting",
+ "communal_lighting_conductor",
+ "communal_store_roof",
+ "communal_store_walls",
+ "communal_store_doors",
+ "communal_warden_call_system",
+ "communal_bms",
+ "communal_booster_pump",
+ "communal_dry_riser",
+ "communal_wet_riser",
+ "communal_cold_water_storage",
+ "communal_sprinkler",
+ "communal_plug_sockets",
+ "communal_circulation_space",
+ "ffhh_damp",
+ "ffhh_hold_and_cold_water",
+ "ffhh_drainage_lavatories",
+ "ffhh_neglected",
+ "ffhh_natural_light",
+ "ffhh_ventilation",
+ "ffhh_food_prep_and_washup",
+ "ffhh_unsafe_layout",
+ "ffhh_unstable_building",
+ "hhsrs_damp_and_mould",
+ "hhsrs_excess_cold",
+ "hhsrs_excess_heat",
+ "hhsrs_asbestos_and_mmf",
+ "hhsrs_biocides",
+ "hhsrs_carbon_monoxide",
+ "hhsrs_lead",
+ "hhsrs_radiation",
+ "hhsrs_uncombusted_fuel_gas",
+ "hhsrs_volatile_organic_compounds",
+ "hhsrs_crowding_and_space",
+ "hhsrs_entry_by_intruders",
+ "hhsrs_lighting",
+ "hhsrs_noise",
+ "hhsrs_domestic_hygiene_pests_refuse",
+ "hhsrs_food_safety",
+ "hhsrs_personal_hygiene_sanitation",
+ "hhsrs_water_supply",
+ "hhsrs_falls_associated_with_baths",
+ "hhsrs_falls_on_level_surfaces",
+ "hhsrs_falls_on_stairs",
+ "hhsrs_falls_between_levels",
+ "hhsrs_electrical_hazards",
+ "hhsrs_fire",
+ "hhsrs_flames_hot_surfaces",
+ "hhsrs_collision_and_entrapment",
+ "hhsrs_collision_hazards_low_headroom",
+ "hhsrs_explosions",
+ "hhsrs_ergonomics",
+ "hhsrs_structural_collapse",
+ "hhsrs_amenities"
+ ]
+ },
+ "public.document_type": {
+ "name": "document_type",
+ "schema": "public",
+ "values": [
+ "EPR",
+ "Condition Report",
+ "Evidence Report",
+ "Summary Information",
+ "Floor Plan",
+ "Scenario Draft EPC",
+ "Scenario Site Notes"
+ ]
+ },
+ "public.scheme": {
+ "name": "scheme",
+ "schema": "public",
+ "values": [
+ "eco4",
+ "gbis",
+ "whlg",
+ "none"
+ ]
+ },
+ "public.inspection_archetype_2": {
+ "name": "inspection_archetype_2",
+ "schema": "public",
+ "values": [
+ "detached",
+ "mid-terrace",
+ "enclosed mid-terrace",
+ "end-terrace",
+ "enclosed end-terrace",
+ "semi-detached"
+ ]
+ },
+ "public.inspection_archetype": {
+ "name": "inspection_archetype",
+ "schema": "public",
+ "values": [
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "House",
+ "non-domestic"
+ ]
+ },
+ "public.inspection_borescoped": {
+ "name": "inspection_borescoped",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "refused"
+ ]
+ },
+ "public.inspections_access_issues": {
+ "name": "inspections_access_issues",
+ "schema": "public",
+ "values": [
+ "see notes",
+ "damp issues",
+ "foliage on walls",
+ "bushes against wall",
+ "trees around/anove property",
+ "high rise block flats/maisonettes",
+ "conservatory",
+ "lean-to",
+ "garage",
+ "extension",
+ "decking",
+ "shed against wall"
+ ]
+ },
+ "public.inspections_cladding": {
+ "name": "inspections_cladding",
+ "schema": "public",
+ "values": [
+ "none",
+ "cladded with “sufficient space to fill the wall”",
+ "cladded with “insufficient space to fill the wall”"
+ ]
+ },
+ "public.inspections_insulation_material": {
+ "name": "inspections_insulation_material",
+ "schema": "public",
+ "values": [
+ "empty 50-90",
+ "empty 100+",
+ "empty 30-40",
+ "empty less than 30",
+ "loose fibre/wool",
+ "eps/celo/king",
+ "fibre batts - with cavity",
+ "fibre batts - no cavity",
+ "loose bead",
+ "glued bead",
+ "formaldehyde",
+ "bubble wrap",
+ "poly chunks"
+ ]
+ },
+ "public.inspections_rendered": {
+ "name": "inspections_rendered",
+ "schema": "public",
+ "values": [
+ "no render",
+ "rendered with “insufficient” space between dpc and render",
+ "rendered with “sufficient” space between dpc and render"
+ ]
+ },
+ "public.inspections_roof_orientation": {
+ "name": "inspections_roof_orientation",
+ "schema": "public",
+ "values": [
+ "north",
+ "east",
+ "south",
+ "west",
+ "north-east",
+ "north-west",
+ "south-east",
+ "south-west",
+ "n/s split",
+ "e/w split",
+ "ne/sw split",
+ "nw/se split",
+ "flat roof",
+ "no roof",
+ "roof too small",
+ "already has solar pv"
+ ]
+ },
+ "public.inspections_tile_hung": {
+ "name": "inspections_tile_hung",
+ "schema": "public",
+ "values": [
+ "yes",
+ "no",
+ "first floor flats are tile hung"
+ ]
+ },
+ "public.inspections_wall_construction": {
+ "name": "inspections_wall_construction",
+ "schema": "public",
+ "values": [
+ "cavity",
+ "solid",
+ "system built",
+ "timber framed",
+ "steel framed",
+ "re-walled cavity",
+ "mansard pre-fab",
+ "mansard ewi",
+ "mansard re-walled"
+ ]
+ },
+ "public.inspections_wall_insulation": {
+ "name": "inspections_wall_insulation",
+ "schema": "public",
+ "values": [
+ "empty cavity",
+ "filled at build",
+ "partial",
+ "retro drilled",
+ "ewi",
+ "iwi",
+ "solid non-cavity",
+ "system built",
+ "timber framed",
+ "steel framed"
+ ]
+ },
+ "public.built_form_type": {
+ "name": "built_form_type",
+ "schema": "public",
+ "values": [
+ "Detached",
+ "Semi-Detached",
+ "Mid-Terrace",
+ "End-Terrace",
+ "Enclosed Mid-Terrace",
+ "Enclosed End-Terrace",
+ "Not Recorded",
+ "Unknown"
+ ]
+ },
+ "public.construction_age_band": {
+ "name": "construction_age_band",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "Unknown"
+ ]
+ },
+ "public.glazing": {
+ "name": "glazing",
+ "schema": "public",
+ "values": [
+ "Single glazing",
+ "Double glazing, 2002 or later",
+ "Double glazing, pre-2002",
+ "Triple glazing, pre-2002",
+ "Triple glazing, 2002 or later",
+ "Mixed glazing",
+ "Secondary glazing",
+ "Unknown"
+ ]
+ },
+ "public.main_fuel": {
+ "name": "main_fuel",
+ "schema": "public",
+ "values": [
+ "mains gas",
+ "mains gas (community)",
+ "electricity",
+ "electricity (community)",
+ "LPG (bulk)",
+ "bottled LPG",
+ "LPG special condition",
+ "oil",
+ "house coal",
+ "smokeless coal",
+ "dual fuel (mineral and wood)",
+ "biomass (community)",
+ "wood logs",
+ "Unknown"
+ ]
+ },
+ "public.main_heating_system": {
+ "name": "main_heating_system",
+ "schema": "public",
+ "values": [
+ "Gas boiler, combi",
+ "Gas boiler, regular",
+ "Gas CPSU",
+ "Electric storage heaters, old",
+ "Electric storage heaters, slimline",
+ "Electric storage heaters, convector",
+ "Electric storage heaters, fan",
+ "Direct-acting electric",
+ "Electric room heaters",
+ "Solid fuel room heater, closed",
+ "Air source heat pump",
+ "Community heating, boilers",
+ "Community heating, CHP and boilers",
+ "Oil room heater, 2000 or later",
+ "Gas room heater, condensing fire",
+ "Gas room heater, decorative fuel-effect",
+ "Gas room heater, flush live-effect",
+ "Gas room heater, open flue 1980 or later",
+ "Gas room heater, open flue pre-1980",
+ "Electric storage heaters, high heat retention",
+ "Solid fuel room heater, open fire",
+ "Solid fuel room heater, open fire with back boiler",
+ "Solid fuel room heater, closed with boiler",
+ "Electric boiler",
+ "Electric CPSU",
+ "Electric underfloor, in concrete slab (off-peak)",
+ "Electric underfloor, integrated storage and direct-acting",
+ "Electric underfloor, in screed above insulation",
+ "Unknown"
+ ]
+ },
+ "public.override_source": {
+ "name": "override_source",
+ "schema": "public",
+ "values": [
+ "classifier",
+ "user",
+ "os_places"
+ ]
+ },
+ "public.property_type": {
+ "name": "property_type",
+ "schema": "public",
+ "values": [
+ "House",
+ "Bungalow",
+ "Flat",
+ "Maisonette",
+ "Park home",
+ "Unknown"
+ ]
+ },
+ "public.roof_type": {
+ "name": "roof_type",
+ "schema": "public",
+ "values": [
+ "Flat, insulated",
+ "Flat, insulated (assumed)",
+ "Flat, limited insulation",
+ "Flat, limited insulation (assumed)",
+ "Flat, no insulation",
+ "Flat, no insulation (assumed)",
+ "Flat, 12 mm insulation",
+ "Flat, 25 mm insulation",
+ "Flat, 50 mm insulation",
+ "Flat, 75 mm insulation",
+ "Flat, 100 mm insulation",
+ "Flat, 125 mm insulation",
+ "Flat, 150 mm insulation",
+ "Flat, 175 mm insulation",
+ "Flat, 200 mm insulation",
+ "Flat, 225 mm insulation",
+ "Flat, 250 mm insulation",
+ "Flat, 270 mm insulation",
+ "Flat, 300 mm insulation",
+ "Flat, 350 mm insulation",
+ "Flat, 400 mm insulation",
+ "Flat, 400+ mm insulation",
+ "Pitched, insulated",
+ "Pitched, insulated (assumed)",
+ "Pitched, insulated at rafters",
+ "Pitched, limited insulation",
+ "Pitched, limited insulation (assumed)",
+ "Pitched, no insulation",
+ "Pitched, no insulation (assumed)",
+ "Pitched, Unknown loft insulation",
+ "Pitched, 0 mm loft insulation",
+ "Pitched, 12 mm loft insulation",
+ "Pitched, 25 mm loft insulation",
+ "Pitched, 50 mm loft insulation",
+ "Pitched, 75 mm loft insulation",
+ "Pitched, 100 mm loft insulation",
+ "Pitched, 125 mm loft insulation",
+ "Pitched, 150 mm loft insulation",
+ "Pitched, 175 mm loft insulation",
+ "Pitched, 200 mm loft insulation",
+ "Pitched, 225 mm loft insulation",
+ "Pitched, 250 mm loft insulation",
+ "Pitched, 270 mm loft insulation",
+ "Pitched, 300 mm loft insulation",
+ "Pitched, 350 mm loft insulation",
+ "Pitched, 400 mm loft insulation",
+ "Pitched, 400+ mm loft insulation",
+ "Roof room(s), insulated",
+ "Roof room(s), insulated (assumed)",
+ "Roof room(s), limited insulation",
+ "Roof room(s), limited insulation (assumed)",
+ "Roof room(s), no insulation",
+ "Roof room(s), no insulation (assumed)",
+ "Roof room(s), ceiling insulated",
+ "Roof room(s), thatched",
+ "Roof room(s), thatched with additional insulation",
+ "Thatched",
+ "Thatched, with additional insulation",
+ "(another dwelling above)",
+ "(same dwelling above)",
+ "(other premises above)",
+ "(another premises above)",
+ "Another Premises Above",
+ "Unknown"
+ ]
+ },
+ "public.wall_type": {
+ "name": "wall_type",
+ "schema": "public",
+ "values": [
+ "Cavity wall, filled cavity",
+ "Cavity wall, as built, insulated (assumed)",
+ "Cavity wall, as built, no insulation (assumed)",
+ "Cavity wall, as built, partial insulation (assumed)",
+ "Cavity wall, with internal insulation",
+ "Cavity wall, with external insulation",
+ "Cavity wall, filled cavity and internal insulation",
+ "Cavity wall, filled cavity and external insulation",
+ "Solid brick, as built, no insulation (assumed)",
+ "Solid brick, as built, insulated (assumed)",
+ "Solid brick, as built, partial insulation (assumed)",
+ "Solid brick, with internal insulation",
+ "Solid brick, with external insulation",
+ "Timber frame, as built, no insulation (assumed)",
+ "Timber frame, as built, insulated (assumed)",
+ "Timber frame, as built, partial insulation (assumed)",
+ "Timber frame, with additional insulation",
+ "Sandstone, as built, no insulation (assumed)",
+ "Sandstone, as built, insulated (assumed)",
+ "Sandstone, as built, partial insulation (assumed)",
+ "Sandstone, with internal insulation",
+ "Sandstone, with external insulation",
+ "Granite or whin, as built, no insulation (assumed)",
+ "Granite or whin, as built, insulated (assumed)",
+ "Granite or whin, as built, partial insulation (assumed)",
+ "Granite or whin, with internal insulation",
+ "Granite or whin, with external insulation",
+ "System built, as built, no insulation (assumed)",
+ "System built, as built, insulated (assumed)",
+ "System built, as built, partial insulation (assumed)",
+ "System built, with internal insulation",
+ "System built, with external insulation",
+ "Park home wall, as built",
+ "Park home wall, with internal insulation",
+ "Park home wall, with external insulation",
+ "Cob, as built",
+ "Cob, with internal insulation",
+ "Cob, with external insulation",
+ "Curtain wall",
+ "Curtain Wall, as built, no insulation (assumed)",
+ "Curtain Wall, as built, insulated (assumed)",
+ "Curtain Wall, filled cavity",
+ "Curtain Wall, with internal insulation",
+ "Basement wall",
+ "Basement wall, as built",
+ "Unknown"
+ ]
+ },
+ "public.water_heating": {
+ "name": "water_heating",
+ "schema": "public",
+ "values": [
+ "From main system, mains gas",
+ "From main system, electricity",
+ "From main system, oil",
+ "From main system, LPG (bulk)",
+ "From main system, bottled LPG",
+ "From main system, house coal",
+ "Electric immersion, electricity",
+ "Gas boiler/circulator, mains gas",
+ "From main system, wood logs",
+ "From main system, biomass (community)",
+ "From main system, dual fuel (mineral and wood)",
+ "From main system, biodiesel (community)",
+ "Unknown"
+ ]
+ },
+ "public.cost_unit": {
+ "name": "cost_unit",
+ "schema": "public",
+ "values": [
+ "gbp_sq_meter",
+ "gbp_per_unit",
+ "gbp_per_m2",
+ "gbp_per_m"
+ ]
+ },
+ "public.depth_unit": {
+ "name": "depth_unit",
+ "schema": "public",
+ "values": [
+ "mm"
+ ]
+ },
+ "public.type": {
+ "name": "type",
+ "schema": "public",
+ "values": [
+ "suspended_floor_insulation",
+ "solid_floor_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "cavity_wall_insulation",
+ "mechanical_ventilation",
+ "loft_insulation",
+ "exposed_floor_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "cavity_wall_extraction",
+ "iwi_wall_demolition",
+ "iwi_vapour_barrier",
+ "iwi_redecoration",
+ "suspended_floor_demolition",
+ "suspended_floor_redecoration",
+ "suspended_floor_vapour_barrier",
+ "solid_floor_demolition",
+ "solid_floor_preparation",
+ "solid_floor_vapour_barrier",
+ "solid_floor_redecoration",
+ "ewi_wall_demolition",
+ "ewi_wall_preparation",
+ "ewi_wall_redecoration",
+ "low_energy_lighting_installation",
+ "flat_roof_preparation",
+ "flat_roof_vapour_barrier",
+ "flat_roof_waterproofing",
+ "windows_glazing",
+ "secondary_glazing",
+ "double_glazing",
+ "trickle_vent",
+ "door_undercut",
+ "solar_pv",
+ "solar_battery",
+ "scaffolding",
+ "high_heat_retention_storage_heaters",
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "sealing_fireplace"
+ ]
+ },
+ "public.r_value_unit": {
+ "name": "r_value_unit",
+ "schema": "public",
+ "values": [
+ "square_meter_kelvin_per_watt"
+ ]
+ },
+ "public.size_unit": {
+ "name": "size_unit",
+ "schema": "public",
+ "values": [
+ "kWp",
+ "kW",
+ "watt",
+ "storey"
+ ]
+ },
+ "public.thermal_conductivity_unit": {
+ "name": "thermal_conductivity_unit",
+ "schema": "public",
+ "values": [
+ "watt_per_meter_kelvin"
+ ]
+ },
+ "public.goal": {
+ "name": "goal",
+ "schema": "public",
+ "values": [
+ "Valuation Improvement",
+ "Increasing EPC",
+ "Reducing CO2 emissions",
+ "Energy Savings",
+ "None"
+ ]
+ },
+ "public.portfolio_capability": {
+ "name": "portfolio_capability",
+ "schema": "public",
+ "values": [
+ "approver",
+ "contractor"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "creator",
+ "admin",
+ "read",
+ "write"
+ ]
+ },
+ "public.status": {
+ "name": "status",
+ "schema": "public",
+ "values": [
+ "scoping",
+ "survey",
+ "assessment",
+ "tendering",
+ "project underway",
+ "completion; status: on track",
+ "completion; status: delayed",
+ "completion; status: at risk",
+ "completion; status: completed",
+ "needs review"
+ ]
+ },
+ "public.override_component": {
+ "name": "override_component",
+ "schema": "public",
+ "values": [
+ "wall_type",
+ "roof_type",
+ "property_type",
+ "built_form_type",
+ "main_fuel",
+ "glazing",
+ "construction_age_band",
+ "water_heating",
+ "main_heating_system"
+ ]
+ },
+ "public.energy_element_type": {
+ "name": "energy_element_type",
+ "schema": "public",
+ "values": [
+ "roof",
+ "wall",
+ "floor",
+ "main_heating",
+ "window",
+ "lighting",
+ "hot_water",
+ "secondary_heating",
+ "main_heating_controls"
+ ]
+ },
+ "public.epc": {
+ "name": "epc",
+ "schema": "public",
+ "values": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ]
+ },
+ "public.creation_status": {
+ "name": "creation_status",
+ "schema": "public",
+ "values": [
+ "LOADING",
+ "READY",
+ "ERROR"
+ ]
+ },
+ "public.rebaseline_reason": {
+ "name": "rebaseline_reason",
+ "schema": "public",
+ "values": [
+ "none",
+ "pre_sap10",
+ "physical_state_changed",
+ "both"
+ ]
+ },
+ "public.housing_type": {
+ "name": "housing_type",
+ "schema": "public",
+ "values": [
+ "Private",
+ "Social"
+ ]
+ },
+ "public.measure_type": {
+ "name": "measure_type",
+ "schema": "public",
+ "values": [
+ "air_source_heat_pump",
+ "boiler_upgrade",
+ "high_heat_retention_storage_heaters",
+ "secondary_heating",
+ "roomstat_programmer_trvs",
+ "time_temperature_zone_control",
+ "cylinder_thermostat",
+ "cavity_wall_insulation",
+ "extension_cavity_wall_insulation",
+ "external_wall_insulation",
+ "internal_wall_insulation",
+ "loft_insulation",
+ "flat_roof_insulation",
+ "room_roof_insulation",
+ "solid_floor_insulation",
+ "suspended_floor_insulation",
+ "double_glazing",
+ "secondary_glazing",
+ "draught_proofing",
+ "mechanical_ventilation",
+ "low_energy_lighting",
+ "solar_pv",
+ "hot_water_tank_insulation",
+ "sealing_open_fireplace"
+ ]
+ },
+ "public.plan_type": {
+ "name": "plan_type",
+ "schema": "public",
+ "values": [
+ "solar_eco4",
+ "solar_hhrsh_eco4",
+ "empty_cavity_eco",
+ "partial_cavity_eco",
+ "extraction_eco"
+ ]
+ },
+ "public.unit_quantity": {
+ "name": "unit_quantity",
+ "schema": "public",
+ "values": [
+ "m2",
+ "part",
+ "kwp"
+ ]
+ },
+ "public.scenario_type": {
+ "name": "scenario_type",
+ "schema": "public",
+ "values": [
+ "unit",
+ "building"
+ ]
+ },
+ "public.source": {
+ "name": "source",
+ "schema": "public",
+ "values": [
+ "portfolio_id",
+ "hubspot_deal_id",
+ "property_id"
+ ]
+ },
+ "public.file_source": {
+ "name": "file_source",
+ "schema": "public",
+ "values": [
+ "pas hub",
+ "sharepoint",
+ "hubspot",
+ "ecmk",
+ "contractor",
+ "magic_plan",
+ "coordination_hub",
+ "audit_generator"
+ ]
+ },
+ "public.file_type": {
+ "name": "file_type",
+ "schema": "public",
+ "values": [
+ "photo_pack",
+ "site_note",
+ "rd_sap_site_note",
+ "pas_2023_ventilation",
+ "pas_2023_condition",
+ "pas_significance",
+ "par_photo_pack",
+ "pas_2023_property",
+ "pas_2023_occupancy",
+ "ecmk_site_note",
+ "ecmk_rd_sap_site_note",
+ "ecmk_survey_xml",
+ "pre_photo",
+ "mid_photo",
+ "post_photo",
+ "loft_hatch_photo",
+ "dmev_photos",
+ "door_undercut_photos",
+ "trickle_vent_photos",
+ "pre_installation_building_inspection",
+ "point_of_work_risk_assessment",
+ "claim_of_compliance",
+ "mcs_compliance_certificate",
+ "certificate_of_conformity",
+ "minor_works_electrical_certificate",
+ "trustmark_licence_numbers",
+ "operative_competency",
+ "ventilation_assessment_checklist",
+ "anemometer_readings",
+ "commissioning_records",
+ "part_f_ventilation_document",
+ "handover_pack",
+ "insurance_guarantee",
+ "workmanship_warranty",
+ "g98_notification",
+ "installer_qualifications",
+ "installer_feedback",
+ "contractor_other",
+ "magic_plan_json",
+ "improvement_option_evaluation",
+ "medium_term_improvement_plan",
+ "retrofit_design_doc",
+ "ventilation_audit",
+ "other"
+ ]
+ },
+ "public.user_defined_deal_measure_source": {
+ "name": "user_defined_deal_measure_source",
+ "schema": "public",
+ "values": [
+ "instructed",
+ "pibi_ordered"
+ ]
+ },
+ "public.user_profiles_property_count": {
+ "name": "user_profiles_property_count",
+ "schema": "public",
+ "values": [
+ "1",
+ "2–5",
+ "6–20",
+ "21+",
+ "1–50",
+ "51–100",
+ "101–300",
+ "301–1000",
+ "1000+"
+ ]
+ },
+ "public.user_profiles_referral_source": {
+ "name": "user_profiles_referral_source",
+ "schema": "public",
+ "values": [
+ "search",
+ "social_media",
+ "NRLA",
+ "partner",
+ "word_of_mouth",
+ "other"
+ ]
+ },
+ "public.user_profiles_user_type": {
+ "name": "user_profiles_user_type",
+ "schema": "public",
+ "values": [
+ "private_landlord",
+ "private_tenant",
+ "social_landlord",
+ "social_tenant",
+ "homeowner",
+ "other"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/src/app/db/migrations/meta/_journal.json b/src/app/db/migrations/meta/_journal.json
index cec17fa6..0c0d509e 100644
--- a/src/app/db/migrations/meta/_journal.json
+++ b/src/app/db/migrations/meta/_journal.json
@@ -1849,6 +1849,62 @@
"when": 1783430551377,
"tag": "0264_yummy_master_chief",
"breakpoints": true
+ },
+ {
+ "idx": 265,
+ "version": "7",
+ "when": 1783446767021,
+ "tag": "0265_uprn_corrections",
+ "breakpoints": true
+ },
+ {
+ "idx": 266,
+ "version": "7",
+ "when": 1783511384352,
+ "tag": "0266_hesitant_bromley",
+ "breakpoints": true
+ },
+ {
+ "idx": 267,
+ "version": "7",
+ "when": 1783521828294,
+ "tag": "0267_add_hubspot_deal_planning_columns",
+ "breakpoints": true
+ },
+ {
+ "idx": 268,
+ "version": "7",
+ "when": 1783596612599,
+ "tag": "0268_free_magneto",
+ "breakpoints": true
+ },
+ {
+ "idx": 269,
+ "version": "7",
+ "when": 1783933385119,
+ "tag": "0269_lyrical_sway",
+ "breakpoints": true
+ },
+ {
+ "idx": 270,
+ "version": "7",
+ "when": 1783953369297,
+ "tag": "0270_epc_main_heating_detail_epc_property_index",
+ "breakpoints": true
+ },
+ {
+ "idx": 271,
+ "version": "7",
+ "when": 1783957414552,
+ "tag": "0271_portfolio_tag_and_property_tag",
+ "breakpoints": true
+ },
+ {
+ "idx": 272,
+ "version": "7",
+ "when": 1784292106010,
+ "tag": "0272_flashy_brood",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/src/app/db/schema/bulk_upload_uprn_corrections.ts b/src/app/db/schema/bulk_upload_uprn_corrections.ts
new file mode 100644
index 00000000..108ee118
--- /dev/null
+++ b/src/app/db/schema/bulk_upload_uprn_corrections.ts
@@ -0,0 +1,46 @@
+import { pgTable, uuid, text, boolean, timestamp, unique } from "drizzle-orm/pg-core";
+
+import { bulkAddressUploads } from "./bulk_address_uploads";
+
+// User confirmations of a combiner row's UPRN, captured on the pre-finalise
+// "Addresses" review tab (ADR-0057). address2uprn withholds ambiguous / no-UPRN
+// matches; the user resolves each flagged row via OS Places here, keyed by the
+// combiner CSV's `source_row_id` (there is no `property.id` yet — the finaliser
+// creates identities). At dispatchFinaliser these corrections are overlaid onto
+// the combiner CSV before the finaliser reads it, so the confirmed UPRN drives
+// both the identity insert and property_overrides in one pass — no post-finalise
+// backfill (which is why the portfolio "Unmatched" tab is retired).
+//
+// A row is resolved when it has a numeric `uprn` OR `markedNoUprn = true` (the
+// user asserts no UPRN exists — an accepted terminal state; the finaliser
+// leaves it as a no-UPRN property).
+export const bulkUploadUprnCorrections = pgTable(
+ "bulk_upload_uprn_corrections",
+ {
+ id: uuid("id").defaultRandom().primaryKey(),
+ uploadId: uuid("upload_id")
+ .notNull()
+ .references(() => bulkAddressUploads.id, { onDelete: "cascade" }),
+ // The combiner CSV join key (synthetic UUID minted at start-address-matching).
+ sourceRowId: text("source_row_id").notNull(),
+ // The confirmed UPRN; null when markedNoUprn.
+ uprn: text("uprn"),
+ address: text("address"),
+ postcode: text("postcode"),
+ // The user asserts this address has no UPRN — resolved without one.
+ markedNoUprn: boolean("marked_no_uprn").notNull().default(false),
+ userId: text("user_id"),
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
+ updatedAt: timestamp("updated_at", { withTimezone: true })
+ .notNull()
+ .defaultNow()
+ .$onUpdate(() => new Date()),
+ },
+ (t) => ({
+ // One correction per combiner row — the confirm action upserts on this.
+ uploadRowUnique: unique("bulk_upload_uprn_corrections_upload_row_unique").on(
+ t.uploadId,
+ t.sourceRowId,
+ ),
+ }),
+);
diff --git a/src/app/db/schema/crm/hubspot_deal_table.ts b/src/app/db/schema/crm/hubspot_deal_table.ts
index 4084e5b9..bd01b87c 100644
--- a/src/app/db/schema/crm/hubspot_deal_table.ts
+++ b/src/app/db/schema/crm/hubspot_deal_table.ts
@@ -82,6 +82,16 @@ export const hubspotDealData = pgTable("hubspot_deal_data", {
numberOfAttempts: text("number_of_attempts"),
clientBookingReference: text("client_booking_reference"),
+ thirdPartySurveyorIdentifier: text("third_party_surveyor_identifier"),
+
+ designConstraints: text("design_constraints"),
+ planningComments: text("planning_comments"),
+ planningStatus: text("planning_status"),
+ planningSuggestedApproach: text("planning_suggested_approach"),
+ planningAuthority: text("planning_authority"),
+ designatedArea: text("designated_area"),
+ article4PdRights: text("article_4_pd_rights"),
+ listedBuilding: text("listed_building"),
createdAt: timestamp("created_at", { precision: 6, withTimezone: true })
.defaultNow()
diff --git a/src/app/db/schema/property.ts b/src/app/db/schema/property.ts
index cb73917e..9158103b 100644
--- a/src/app/db/schema/property.ts
+++ b/src/app/db/schema/property.ts
@@ -410,12 +410,23 @@ export interface PropertyWithRelations extends Record {
// Optional columns (hidden by default)
propertyType: string | null;
builtForm: string | null;
- tenure: string | null;
yearBuilt: string | null;
totalFloorArea: number | null;
co2Emissions: number | null;
mainfuel: string | null;
+ wallType: string | null;
+ roofType: string | null;
+ heatingSystem: string | null;
lexiscore: number | null;
+ // Portfolio Tags on this property (ADR-0013), name-ordered; [] when untagged.
+ tags: PropertyTag[];
+}
+
+/** A Tag as it appears on a property row (id serialised to a string). */
+export interface PropertyTag {
+ id: string;
+ name: string;
+ colour: string;
}
export type NonIntrusiveSurveyNotes = InferModel<
@@ -719,6 +730,12 @@ export const epcMainHeatingDetail = pgTable(
communityHeatingBoilerFuelType: integer("community_heating_boiler_fuel_type"), // SAP fuel code, nullable
communityHeatingChpFraction: real("community_heating_chp_fraction"), // 0..1 fraction, nullable
},
+ (table) => [
+ // The portfolio list resolves Main Fuel per row via a correlated subquery on
+ // epc_property_id (mainfuelSql, ADR-0012); without this index that seq-scans
+ // the table for every property in the count/export path.
+ index("ix_epc_main_heating_detail_epc_property").on(table.epcPropertyId),
+ ],
);
// ─── epc_building_part ────────────────────────────────────────────────────────
diff --git a/src/app/db/schema/recommendations.ts b/src/app/db/schema/recommendations.ts
index af7acf0e..ed167389 100644
--- a/src/app/db/schema/recommendations.ts
+++ b/src/app/db/schema/recommendations.ts
@@ -118,6 +118,26 @@ export const recommendation = pgTable(
sql`${table.default} = true AND ${table.alreadyInstalled} = false`,
),
+ // Covering partial index for the reporting "where the money goes"
+ // aggregate, which joins the latest plan per property to its
+ // recommendations ON plan_id, filters to the default active set, and sums
+ // estimated_cost / counts property_id per measure_type. The plain
+ // idx_recommendation_plan_id only locates the rows — the aggregate then
+ // heap-fetches every recommendation to apply the filter and read these
+ // columns, which times out on large portfolios. Carrying measure_type,
+ // property_id and estimated_cost as key columns (drizzle-orm has no
+ // INCLUDE) makes the whole aggregate index-only.
+ index("idx_recommendation_plan_default")
+ .on(
+ table.planId,
+ table.measureType,
+ table.propertyId,
+ table.estimatedCost,
+ )
+ .where(
+ sql`${table.default} = true AND ${table.alreadyInstalled} = false`,
+ ),
+
index("idx_recommendation_material_id").on(table.materialId),
],
);
@@ -241,6 +261,15 @@ export const plan = pgTable(
table.propertyId,
table.createdAt.desc(),
),
+ // Serves the default-plan LATERAL in the property-list query (getProperties):
+ // "latest default plan for this property". The existing indexes lead with
+ // (portfolio_id, scenario_id, …), so with scenario_id unconstrained the LATERAL
+ // scans the whole portfolio's plans per property (~11.5ms × N rows). Leading
+ // with property_id turns it into a direct seek. Partial on is_default keeps it
+ // lean. See PR investigation of portfolio/796 (~12s → ~sub-second).
+ index("idx_plan_property_default_latest")
+ .on(table.propertyId, table.portfolioId, table.createdAt.desc())
+ .where(sql`is_default = true`),
],
);
@@ -298,6 +327,7 @@ export const scenario = pgTable("scenario", {
exclusions: text("exclusions"),
multiPlan: boolean("multi_plan"),
isDefault: boolean("is_default").notNull(),
+ fabricFirst: boolean("fabric_first").notNull().default(false),
// Aggregations that were previously being stored against the portfolio, that are now being stored against the scenario
cost: real("cost"),
contingency: real("contingency"),
diff --git a/src/app/db/schema/tags.ts b/src/app/db/schema/tags.ts
new file mode 100644
index 00000000..1d34eb06
--- /dev/null
+++ b/src/app/db/schema/tags.ts
@@ -0,0 +1,87 @@
+import {
+ bigint,
+ bigserial,
+ index,
+ pgTable,
+ primaryKey,
+ text,
+ timestamp,
+ uniqueIndex,
+} from "drizzle-orm/pg-core";
+import { relations, sql } from "drizzle-orm";
+import { portfolio } from "./portfolio";
+import { property } from "./property";
+
+// A Tag is a user-created, coloured label owned by a Portfolio, used to form an
+// arbitrary group of its Properties for bulk actions (CONTEXT.md, ADR-0013).
+// Flat (no hierarchy) and many-to-many with Property via `property_tag`.
+export const portfolioTag = pgTable(
+ "portfolio_tag",
+ {
+ id: bigserial("id", { mode: "bigint" }).primaryKey(),
+ portfolioId: bigint("portfolio_id", { mode: "bigint" })
+ .notNull()
+ .references(() => portfolio.id, { onDelete: "cascade" }),
+ name: text("name").notNull(),
+ // Freeform hex string (e.g. "#7C3AED"); format is validated in the app.
+ colour: text("colour").notNull(),
+ createdAt: timestamp("created_at", { withTimezone: true })
+ .notNull()
+ .defaultNow(),
+ updatedAt: timestamp("updated_at", { withTimezone: true })
+ .notNull()
+ .defaultNow()
+ .$onUpdate(() => new Date()),
+ },
+ (table) => [
+ // Names are unique within a Portfolio, case-insensitively ("Void" vs "void").
+ uniqueIndex("uq_portfolio_tag_portfolio_lower_name").on(
+ table.portfolioId,
+ sql`lower(${table.name})`,
+ ),
+ ],
+);
+
+// The many-to-many membership: one row per (Property, Tag). Both FKs cascade —
+// deleting a Tag drops its memberships (ADR-0013, hard delete), and deleting a
+// Property drops its tags.
+export const propertyTag = pgTable(
+ "property_tag",
+ {
+ propertyId: bigint("property_id", { mode: "bigint" })
+ .notNull()
+ .references(() => property.id, { onDelete: "cascade" }),
+ tagId: bigint("tag_id", { mode: "bigint" })
+ .notNull()
+ .references(() => portfolioTag.id, { onDelete: "cascade" }),
+ createdAt: timestamp("created_at", { withTimezone: true })
+ .notNull()
+ .defaultNow(),
+ },
+ (table) => [
+ // A Property can't hold the same Tag twice.
+ primaryKey({ columns: [table.propertyId, table.tagId] }),
+ // The composite PK leads with property_id; reverse lookups ("all Properties
+ // for this Tag" — chips, filter, run resolution) need a tag_id-leading index.
+ index("ix_property_tag_tag").on(table.tagId),
+ ],
+);
+
+export const portfolioTagRelations = relations(portfolioTag, ({ one, many }) => ({
+ portfolio: one(portfolio, {
+ fields: [portfolioTag.portfolioId],
+ references: [portfolio.id],
+ }),
+ memberships: many(propertyTag),
+}));
+
+export const propertyTagRelations = relations(propertyTag, ({ one }) => ({
+ tag: one(portfolioTag, {
+ fields: [propertyTag.tagId],
+ references: [portfolioTag.id],
+ }),
+ property: one(property, {
+ fields: [propertyTag.propertyId],
+ references: [property.id],
+ }),
+}));
diff --git a/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/AddressesPanel.tsx b/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/AddressesPanel.tsx
new file mode 100644
index 00000000..cbff4d3f
--- /dev/null
+++ b/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/AddressesPanel.tsx
@@ -0,0 +1,322 @@
+"use client";
+
+import { useState } from "react";
+import { MagnifyingGlassIcon, CheckCircleIcon } from "@heroicons/react/24/outline";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@/app/shadcn_components/ui/dialog";
+import { describeCandidate } from "@/lib/postcodeSearch/model";
+import { searchAddresses, type SearchCandidate } from "@/lib/properties/client";
+import { useSaveUprnCorrection, type FlaggedAddress } from "@/lib/bulkUpload/client";
+
+// The pre-finalise "Addresses" review tab (ADR-0057). Lists the combiner rows
+// address2uprn could not confidently match; the user resolves each via Ordnance
+// Survey (residential candidates only → a guaranteed valid UPRN) or marks it as
+// having no UPRN. Confirmations are saved as corrections (keyed by
+// source_row_id) and overlaid onto the combiner CSV at finalise.
+export default function AddressesPanel({
+ flagged,
+ portfolioId,
+ uploadId,
+}: {
+ flagged: FlaggedAddress[];
+ portfolioId: string;
+ uploadId: string;
+}) {
+ return (
+
+
+
+ Addresses that need a UPRN
+
+
+ We couldn't confidently match these to Ordnance Survey. Pick the
+ right address — or mark it as having no UPRN — so onboarding creates the
+ correct property.
+
+
+
+ {flagged.length === 0 ? (
+
Nothing to resolve.
+ ) : (
+
+ {flagged.map((row) => (
+
+ ))}
+
+ )}
+
+ );
+}
+
+function statusLabel(status: string): string {
+ switch (status) {
+ case "ambiguous_duplicate":
+ return "Ambiguous match";
+ case "low_score":
+ return "Low-confidence match";
+ case "unmatched":
+ return "No match";
+ case "invalid_postcode":
+ return "Invalid postcode";
+ case "error":
+ return "Match error";
+ default:
+ return status;
+ }
+}
+
+function AddressRow({
+ row,
+ portfolioId,
+ uploadId,
+}: {
+ row: FlaggedAddress;
+ portfolioId: string;
+ uploadId: string;
+}) {
+ const save = useSaveUprnCorrection(portfolioId, uploadId);
+ const [open, setOpen] = useState(false);
+ const [address, setAddress] = useState(row.address ?? "");
+ const [postcode, setPostcode] = useState(row.postcode ?? "");
+ // null = not searched yet; [] = searched, no residential matches.
+ const [residential, setResidential] = useState(null);
+ const [selected, setSelected] = useState(null);
+ const [source, setSource] = useState<"cache" | "live" | null>(null);
+ const [searching, setSearching] = useState(false);
+ const [searchError, setSearchError] = useState(null);
+
+ async function runSearch() {
+ setSearching(true);
+ setSearchError(null);
+ setResidential(null);
+ setSelected(null);
+ try {
+ const result = await searchAddresses(portfolioId, postcode);
+ // Residential only — we never assign a non-residential UPRN.
+ setResidential(result.candidates.filter((c) => c.selectable));
+ setSource(result.source);
+ } catch (e) {
+ setSearchError(e instanceof Error ? e.message : "Search failed.");
+ } finally {
+ setSearching(false);
+ }
+ }
+
+ function onAssign() {
+ if (!selected) return;
+ save.mutate(
+ {
+ sourceRowId: row.sourceRowId,
+ uprn: selected.uprn,
+ address: selected.address,
+ postcode: selected.postcode,
+ },
+ { onSuccess: () => setOpen(false) },
+ );
+ }
+
+ function onNoUprn() {
+ save.mutate({ sourceRowId: row.sourceRowId, markedNoUprn: true });
+ }
+
+ return (
+
+
+
+ {row.address || "(no address)"}
+
+
+ {row.postcode || "no postcode"}
+ {row.lexiscore != null ? ` · score ${row.lexiscore.toFixed(2)}` : ""}
+ {" · "}
+ {statusLabel(row.status)}
+
+ {row.resolved && (
+
+
+ {row.markedNoUprn
+ ? "Marked: no UPRN"
+ : `UPRN ${row.resolvedUprn}${row.resolvedAddress ? ` · ${row.resolvedAddress}` : ""}`}
+
+ )}
+
+
+
+ {row.resolved ? (
+ setOpen(true)}
+ className="text-xs text-gray-500 underline underline-offset-2 hover:text-gray-800"
+ >
+ Change
+
+ ) : (
+ <>
+ setOpen(true)}
+ className="inline-flex items-center gap-1.5 rounded-lg border border-amber-300 bg-white px-3 py-1.5 text-xs font-semibold text-amber-800 transition-colors hover:bg-amber-100"
+ >
+
+ Find UPRN
+
+
+ No UPRN
+
+ >
+ )}
+
+
+
+
+
+ Match to a UPRN
+
+ Confirm the postcode and pick the matching address. Only residential
+ addresses from Ordnance Survey are shown, so the UPRN is always valid.
+
+
+
+
+
+
+ Address
+
+ setAddress(e.target.value)}
+ placeholder="e.g. 20 Brenchley Road"
+ className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-amber-400 focus:outline-none focus:ring-1 focus:ring-amber-400"
+ />
+
+
+
+
+ Postcode
+
+ setPostcode(e.target.value)}
+ placeholder="e.g. BR5 2TD"
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && postcode.trim() && !searching)
+ runSearch();
+ }}
+ className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm uppercase focus:border-amber-400 focus:outline-none focus:ring-1 focus:ring-amber-400"
+ />
+
+
+
+ {searching ? "Searching…" : "Search"}
+
+
+
+ {searchError &&
{searchError}
}
+
+ {residential && (
+
+
+
+ Residential addresses
+
+ {source === "cache" && (
+
+ from cache
+
+ )}
+
+
+ {residential.length === 0 ? (
+
+ No residential addresses found for that postcode.
+
+ ) : (
+
+ {residential.map((c) => {
+ const { label } = describeCandidate(c);
+ const isSelected = selected?.uprn === c.uprn;
+ return (
+
+ setSelected(c)}
+ className={`flex w-full items-start gap-2 px-3 py-2 text-left text-sm transition-colors ${
+ isSelected ? "bg-amber-50" : "hover:bg-gray-50"
+ }`}
+ >
+
+
+
+ {c.address}
+
+
+ UPRN {c.uprn} · {label}
+ {c.alreadyInPortfolio ? " · already in portfolio" : ""}
+
+
+
+
+ );
+ })}
+
+ )}
+
+
+ )}
+
+
+
+ {save.error && (
+
+ {save.error.message}
+
+ )}
+ setOpen(false)}
+ className="rounded-lg px-4 py-2 text-sm font-semibold text-gray-600 hover:bg-gray-100"
+ >
+ Cancel
+
+
+ {save.isPending ? "Assigning…" : "Assign UPRN"}
+
+
+
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/OnboardingProgress.tsx b/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/OnboardingProgress.tsx
index 586b1b1b..61046a8d 100644
--- a/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/OnboardingProgress.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/bulk-upload/[uploadId]/OnboardingProgress.tsx
@@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import Link from "next/link";
import { ArrowRightIcon, CheckCircleIcon } from "@heroicons/react/24/outline";
import {
+ useAddressMatches,
useBulkUploadProgress,
useConfirmMultiEntryOrdering,
useConfirmVerification,
@@ -14,6 +15,7 @@ import {
useSampleClassifications,
type SampleClassifications,
} from "@/lib/bulkUpload/client";
+import AddressesPanel from "./AddressesPanel";
import {
partLabel,
isPermutation,
@@ -69,6 +71,9 @@ export default function OnboardingProgress({
});
const combine = useRequestCombine(portfolioId, uploadId);
const finalize = useFinalize(portfolioId, uploadId);
+ const [reviewTab, setReviewTab] = useState<"classification" | "addresses">(
+ "classification",
+ );
// Read-only classifications for the multi-entry sample (issue #298). Fetched
// only once a sample exists at awaiting_review. Hook stays above the early
@@ -77,6 +82,13 @@ export default function OnboardingProgress({
progress.data?.upload.status === "awaiting_review" &&
!!progress.data.upload.multiEntrySummary?.sample;
const classifications = useSampleClassifications(portfolioId, uploadId, sampleReady);
+ // Combiner rows address2uprn could not confidently match (ADR-0057). Fetched
+ // once at awaiting_review; drives the Addresses tab + the Finalise gate.
+ const addressMatches = useAddressMatches(
+ portfolioId,
+ uploadId,
+ progress.data?.upload.status === "awaiting_review",
+ );
if (progress.isError) return null;
if (!progress.data) {
@@ -139,11 +151,17 @@ export default function OnboardingProgress({
(n, descriptions) => n + descriptions.length,
0,
);
+ // Flagged addresses (no confident UPRN) must all be resolved before finalise,
+ // else a withheld row lands as an unintended no-UPRN property (ADR-0057).
+ const flaggedCount = addressMatches.data?.flagged.length ?? 0;
+ const unresolvedAddresses = addressMatches.data?.unresolved ?? 0;
+ const showAddressTab = isAwaitingReview && flaggedCount > 0;
const canFinalize =
isAwaitingReview &&
(!needsVerify || verifyAck) &&
(!needsOrdering || orderingConfirmed) &&
- unknownTotal === 0;
+ unknownTotal === 0 &&
+ unresolvedAddresses === 0;
return (
@@ -211,47 +229,94 @@ export default function OnboardingProgress({
)}
- {needsVerify && sample && (
-
+ {/* Two-tab review at awaiting_review: classification checks | address/UPRN
+ confirmation (ADR-0057). The Addresses tab only appears when there are
+ flagged rows; otherwise the classification panels render as before. */}
+ {showAddressTab && (
+
+ setReviewTab("classification")}
+ className={`-mb-px border-b-2 px-1 pb-2 transition-colors ${
+ reviewTab === "classification"
+ ? "border-[#14163d] font-medium text-[#14163d]"
+ : "border-transparent text-gray-500 hover:text-gray-700"
+ }`}
+ >
+ Classification
+
+ setReviewTab("addresses")}
+ className={`-mb-px flex items-center gap-1.5 border-b-2 px-1 pb-2 transition-colors ${
+ reviewTab === "addresses"
+ ? "border-[#14163d] font-medium text-[#14163d]"
+ : "border-transparent text-gray-500 hover:text-gray-700"
+ }`}
+ >
+ Addresses
+ {unresolvedAddresses > 0 && (
+
+ {unresolvedAddresses}
+
+ )}
+
+
)}
- {isAwaitingReview && unknownTotal > 0 && (
-
- )}
-
- {needsOrdering && orderingSamples.length > 0 && (
-
- {orderingSamples.map(([count, orderSample], i) => (
-
+ {needsVerify && sample && (
+ 1
- ? `Part group ${i + 1}`
- : undefined
- }
+ verified={verifyAck}
+ stepLabel={showStepNumbers ? "Step 1" : undefined}
portfolioId={portfolioId}
uploadId={uploadId}
/>
- ))}
-
+ )}
+
+ {isAwaitingReview && unknownTotal > 0 && (
+
+ )}
+
+ {needsOrdering && orderingSamples.length > 0 && (
+
+ {orderingSamples.map(([count, orderSample], i) => (
+ 1
+ ? `Part group ${i + 1}`
+ : undefined
+ }
+ portfolioId={portfolioId}
+ uploadId={uploadId}
+ />
+ ))}
+
+ )}
+ >
+ )}
+
+ {showAddressTab && reviewTab === "addresses" && (
+
)}
{(canRunCombiner || isAwaitingReview) && (
@@ -271,11 +336,13 @@ export default function OnboardingProgress({
isPending={finalize.isPending}
disabled={!canFinalize}
disabledReason={
- unknownTotal > 0
- ? `Resolve ${unknownTotal} unclassified description${unknownTotal === 1 ? "" : "s"} first`
- : needsVerify && !verifyAck
- ? "Verify the classification first"
- : "Confirm the building-part order first"
+ unresolvedAddresses > 0
+ ? `Resolve ${unresolvedAddresses} address${unresolvedAddresses === 1 ? "" : "es"} on the Addresses tab first`
+ : unknownTotal > 0
+ ? `Resolve ${unknownTotal} unclassified description${unknownTotal === 1 ? "" : "s"} first`
+ : needsVerify && !verifyAck
+ ? "Verify the classification first"
+ : "Confirm the building-part order first"
}
onClick={() =>
finalize.mutate(undefined, { onSuccess: () => router.refresh() })
diff --git a/src/app/portfolio/[slug]/(portfolio)/page.tsx b/src/app/portfolio/[slug]/(portfolio)/page.tsx
index 4f9b0cde..c3305755 100644
--- a/src/app/portfolio/[slug]/(portfolio)/page.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/page.tsx
@@ -11,9 +11,10 @@ export default async function Page(props: {
const params = await props.params;
const portfolioId = params.slug;
- return (
- <>
-
- >
- );
+ // UPRN matching is now confirmed during bulk-upload onboarding (ADR-0057), so
+ // properties arrive already matched — the portfolio-level "Unmatched" tab is
+ // retired. The tab components (PortfolioTabs / UnmatchedProperties /
+ // getUnmatchedProperties) are left in place for now, pending a follow-up that
+ // reconciles legacy no-UPRN properties onboarded before this feature.
+ return ;
}
diff --git a/src/app/portfolio/[slug]/(portfolio)/scenarios/[scenarioId]/page.tsx b/src/app/portfolio/[slug]/(portfolio)/scenarios/[scenarioId]/page.tsx
index 55fd7b98..a9e3101b 100644
--- a/src/app/portfolio/[slug]/(portfolio)/scenarios/[scenarioId]/page.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/scenarios/[scenarioId]/page.tsx
@@ -7,6 +7,7 @@ import { getScenarioWithPlansCount } from "@/lib/scenarios/queries";
import {
BandChip,
EPC_SOFT,
+ FabricFirstChip,
GOAL_SHORT_LABELS,
GoalIcon,
StatusPill,
@@ -114,7 +115,7 @@ export default async function ScenarioDetailPage(props: {
)}
-
+
Exclusions
{summary.kind === "all" ? (
@@ -151,6 +152,21 @@ export default async function ScenarioDetailPage(props: {
)}
+
+
Fabric first
+
+ {s.fabricFirst ? (
+
+
+
+ insulation, glazing & ventilation before heating & renewables
+
+
+ ) : (
+ Off — measures considered together
+ )}
+
+
diff --git a/src/app/portfolio/[slug]/(portfolio)/scenarios/new/NewScenarioJourney.tsx b/src/app/portfolio/[slug]/(portfolio)/scenarios/new/NewScenarioJourney.tsx
index b3aaea2f..ac9a9d06 100644
--- a/src/app/portfolio/[slug]/(portfolio)/scenarios/new/NewScenarioJourney.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/scenarios/new/NewScenarioJourney.tsx
@@ -24,6 +24,7 @@ interface ExistingScenario {
goalValue: string | null;
budget: number | null;
exclusions: string[];
+ fabricFirst: boolean;
modelled: boolean;
}
@@ -73,6 +74,7 @@ export function NewScenarioJourney({
const [band, setBand] = useState(template?.goalValue ?? null);
const [budget, setBudget] = useState(template?.budget ? String(template.budget) : "");
const [excluded, setExcluded] = useState>(new Set(template?.exclusions ?? []));
+ const [fabricFirst, setFabricFirst] = useState(template?.fabricFirst ?? false);
const [errors, setErrors] = useState<{ name?: string; band?: string; excl?: string }>({});
const isEpc = goal === PORTFOLIO_GOALS.EPC;
@@ -90,6 +92,7 @@ export function NewScenarioJourney({
goalValue: isEpc ? band : null,
budgetPerProperty: budgetNumber,
exclusions: [...excluded],
+ fabricFirst,
}),
});
if (!res.ok) throw new Error((await res.json()).error ?? "Save failed");
@@ -126,6 +129,7 @@ export function NewScenarioJourney({
goalValue: isEpc ? band : null,
budgetPerProperty: budgetNumber,
exclusions: [...excluded],
+ fabricFirst,
},
existing.map((s) => ({
id: BigInt(s.id),
@@ -135,6 +139,7 @@ export function NewScenarioJourney({
goalValue: s.goalValue,
budget: s.budget,
exclusions: s.exclusions.length ? `{${s.exclusions.join(",")}}` : null,
+ fabricFirst: s.fabricFirst,
})),
)
: null;
@@ -455,6 +460,51 @@ export function NewScenarioJourney({
))}
+
+
+
+
+
+
+
+
+
+
+ Optimisation order
+
+ Fabric first
+
+ Insulation, glazing and ventilation are applied first; heating and
+ renewables are only considered if the target isn't met.
+
+
+ setFabricFirst(e.target.checked)}
+ className="mt-1 h-4 w-4 flex-none accent-emerald-600"
+ />
+
{errors.excl && {errors.excl}
}
)}
@@ -542,6 +592,14 @@ export function NewScenarioJourney({
),
],
+ [
+ "Fabric first",
+ fabricFirst ? (
+ "On — fabric before heating & renewables"
+ ) : (
+ Off — measures considered together
+ ),
+ ],
].map(([label, value]) => (
s.id === from) ?? null : null;
diff --git a/src/app/portfolio/[slug]/(portfolio)/scenarios/page.tsx b/src/app/portfolio/[slug]/(portfolio)/scenarios/page.tsx
index ba1afc38..76439ac6 100644
--- a/src/app/portfolio/[slug]/(portfolio)/scenarios/page.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/scenarios/page.tsx
@@ -4,6 +4,7 @@ import { listScenariosWithStatus } from "@/lib/scenarios/queries";
import {
BandChip,
EPC_SOFT,
+ FabricFirstChip,
GOAL_SHORT_LABELS,
GoalIcon,
StatusPill,
@@ -139,6 +140,12 @@ export default async function ScenariosPage(props: {
/property cap
>
) : null}
+ {s.fabricFirst ? (
+ <>
+ {" "}
+ ·
+ >
+ ) : null}
diff --git a/src/app/portfolio/[slug]/(portfolio)/scenarios/ui.tsx b/src/app/portfolio/[slug]/(portfolio)/scenarios/ui.tsx
index ac907289..e7c73080 100644
--- a/src/app/portfolio/[slug]/(portfolio)/scenarios/ui.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/scenarios/ui.tsx
@@ -131,6 +131,19 @@ export function constraintLine(exclusions: string[]): React.ReactNode {
);
}
+/** Small badge marking a fabric-first Scenario. Render only when the flag is set. */
+export function FabricFirstChip({ className = "" }: { className?: string }) {
+ return (
+
+
+ Fabric first
+
+ );
+}
+
export const formatDate = (d: Date | string) =>
new Date(d).toLocaleDateString("en-GB", { day: "2-digit", month: "short", year: "numeric" });
diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/layout.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/layout.tsx
index db1a38bf..11eafddd 100644
--- a/src/app/portfolio/[slug]/(portfolio)/settings/layout.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/settings/layout.tsx
@@ -1,7 +1,7 @@
import { getServerSession } from "next-auth";
import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
import { SettingsSidebarLink } from "./SettingsSidebarLink";
-import { Settings2, Users, Building2, ScrollText } from "lucide-react";
+import { Settings2, Users, Building2, ScrollText, Tag } from "lucide-react";
export default async function SettingsLayout({
children,
@@ -33,6 +33,12 @@ export default async function SettingsLayout({
>
User Access
+
}
+ >
+ Tags
+
{isDomnaUser && (
(null);
+ const [editingId, setEditingId] = useState(null);
+
+ const invalidate = () =>
+ queryClient.invalidateQueries({ queryKey: portfolioTagsKey(portfolioId) });
+
+ const createTag = useMutation({
+ mutationFn: async (input: { name: string; colour: string }) => {
+ const res = await fetch(`/api/portfolio/${portfolioId}/tags`, {
+ method: "POST",
+ body: JSON.stringify(input),
+ });
+ const body = await res.json();
+ if (!res.ok) throw new Error(body.error ?? "Failed to create tag");
+ return body;
+ },
+ onSuccess: () => {
+ setName("");
+ setColour(DEFAULT_COLOUR);
+ setFormError(null);
+ invalidate();
+ },
+ onError: (e: Error) => setFormError(e.message),
+ });
+
+ return (
+
+
Tags
+
+ Group properties to run scenarios on a subset or filter your reporting.
+ Assign tags from the property table.
+
+
+ {/* Create */}
+
+ {formError &&
{formError}
}
+
+ {/* List */}
+ {isLoading ? (
+
Loading…
+ ) : tags.length === 0 ? (
+
No tags yet.
+ ) : (
+
+ {tags.map((tag) =>
+ editingId === tag.id ? (
+ {
+ setEditingId(null);
+ invalidate();
+ }}
+ onCancel={() => setEditingId(null)}
+ />
+ ) : (
+ setEditingId(tag.id)}
+ onDeleted={invalidate}
+ />
+ ),
+ )}
+
+ )}
+
+ );
+}
+
+function TagRow({
+ portfolioId,
+ tag,
+ onEdit,
+ onDeleted,
+}: {
+ portfolioId: string;
+ tag: Tag;
+ onEdit: () => void;
+ onDeleted: () => void;
+}) {
+ const del = useMutation({
+ mutationFn: async () => {
+ const res = await fetch(`/api/portfolio/${portfolioId}/tags/${tag.id}`, {
+ method: "DELETE",
+ });
+ if (!res.ok) throw new Error("Failed to delete tag");
+ },
+ onSuccess: onDeleted,
+ });
+
+ return (
+
+
+
+ {tag.propertyCount} propert{tag.propertyCount === 1 ? "y" : "ies"}
+
+
+
+
+
+
{
+ if (
+ confirm(
+ `Delete "${tag.name}"? This removes it from ${tag.propertyCount} propert${tag.propertyCount === 1 ? "y" : "ies"}.`,
+ )
+ ) {
+ del.mutate();
+ }
+ }}
+ >
+
+
+
+
+ );
+}
+
+function EditRow({
+ portfolioId,
+ tag,
+ onDone,
+ onCancel,
+}: {
+ portfolioId: string;
+ tag: Tag;
+ onDone: () => void;
+ onCancel: () => void;
+}) {
+ const [name, setName] = useState(tag.name);
+ const [colour, setColour] = useState(tag.colour);
+ const [error, setError] = useState(null);
+
+ const save = useMutation({
+ mutationFn: async () => {
+ const res = await fetch(`/api/portfolio/${portfolioId}/tags/${tag.id}`, {
+ method: "PATCH",
+ body: JSON.stringify({ name, colour }),
+ });
+ const body = await res.json();
+ if (!res.ok) throw new Error(body.error ?? "Failed to save");
+ return body;
+ },
+ onSuccess: onDone,
+ onError: (e: Error) => setError(e.message),
+ });
+
+ return (
+
+ setColour(e.target.value)}
+ className="h-8 w-9 rounded-md border border-gray-300 bg-white p-0.5 cursor-pointer"
+ aria-label="Tag colour"
+ />
+ setName(e.target.value)}
+ className="flex-1"
+ />
+ {error && {error} }
+ save.mutate()}
+ title="Save"
+ >
+
+
+
+
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/tags/page.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/tags/page.tsx
new file mode 100644
index 00000000..d2042156
--- /dev/null
+++ b/src/app/portfolio/[slug]/(portfolio)/settings/tags/page.tsx
@@ -0,0 +1,12 @@
+import TagsCard from "./TagsCard";
+
+export default async function TagsSettingsPage(props: {
+ params: Promise<{ slug: string }>;
+}) {
+ const { slug } = await props.params;
+ return (
+
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentBulkDownload.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentBulkDownload.tsx
new file mode 100644
index 00000000..d8b174e8
--- /dev/null
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentBulkDownload.tsx
@@ -0,0 +1,360 @@
+"use client";
+
+import { useState } from "react";
+import { useMutation, useQuery } from "@tanstack/react-query";
+import {
+ PackageCheck,
+ AlertTriangle,
+ X,
+ Download,
+ Loader2,
+ CheckCircle2,
+} from "lucide-react";
+import DocumentTable, { type DocumentSelection } from "./DocumentTable";
+import type {
+ ClassifiedDeal,
+ DocStatusMap,
+ PortfolioCapabilityType,
+ ApprovalsByDeal,
+} from "./types";
+import {
+ MAX_BULK_DOWNLOAD_PROPERTIES,
+ buildSelectionConfig,
+ bulkDownloadRefetchInterval,
+ type BulkDownloadStatus,
+} from "@/lib/bulkDocumentDownload/model";
+
+interface Props {
+ data: ClassifiedDeal[];
+ onOpenDrawer: (
+ dealId: string,
+ uprn: string | null,
+ landlordPropertyId: string | null,
+ dealname: string | null,
+ batch: string | null,
+ batchDescription: string | null,
+ ) => void;
+ docStatusMap: DocStatusMap;
+ portfolioId: string;
+ userCapability: PortfolioCapabilityType;
+ approvalsByDeal?: ApprovalsByDeal;
+ /** Current Documents-tab scope — a real project code or the "__ALL__" sentinel. */
+ currentProjectCode: string;
+}
+
+/** JSON body or null — never throws, so a 504's HTML page can't crash the UI. */
+async function parseBody(res: Response): Promise<{ error?: string; taskId?: string } | null> {
+ const text = await res.text().catch(() => "");
+ if (!text) return null;
+ try {
+ return JSON.parse(text);
+ } catch {
+ return null;
+ }
+}
+
+/**
+ * Bulk document download on the Documents tab: a "Bulk download" button flips the
+ * table into row-selection mode; the picked landlord property ids become a task
+ * whose ZIP is emailed (and shown here while the page stays open). Scoped by the
+ * tab's existing project/group selection.
+ */
+export default function DocumentBulkDownload({
+ data,
+ onOpenDrawer,
+ docStatusMap,
+ portfolioId,
+ userCapability,
+ approvalsByDeal,
+ currentProjectCode,
+}: Props) {
+ const [selecting, setSelecting] = useState(false);
+ const [selectedIds, setSelectedIds] = useState>(new Set());
+ const [done, setDone] = useState<{ taskId: string } | null>(null);
+
+ const landlordPropertyIds = [...selectedIds];
+ const built = buildSelectionConfig({
+ scope: { kind: "project", projectCode: currentProjectCode },
+ includeAll: false,
+ landlordPropertyIds,
+ portfolioId: Number(portfolioId),
+ });
+
+ const trigger = useMutation<{ taskId: string }, Error, void>({
+ mutationFn: async () => {
+ const res = await fetch(`/api/portfolio/${portfolioId}/bulk-document-download`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ scope: { kind: "project", projectCode: currentProjectCode },
+ includeAll: false,
+ landlordPropertyIds,
+ }),
+ });
+ const body = await parseBody(res);
+ if (!res.ok) {
+ throw new Error(
+ body?.error ??
+ (res.status >= 500
+ ? "The server didn’t respond in time. Your download may still be preparing — check your email shortly."
+ : `Couldn’t start the download (${res.status}).`),
+ );
+ }
+ if (!body?.taskId) throw new Error("Unexpected response from the server.");
+ return { taskId: body.taskId };
+ },
+ onSuccess: ({ taskId }) => {
+ setDone({ taskId });
+ setSelecting(false);
+ setSelectedIds(new Set());
+ },
+ });
+
+ const status = useQuery({
+ queryKey: ["bulk-download-status", portfolioId, done?.taskId],
+ enabled: !!done,
+ refetchInterval: (d) => bulkDownloadRefetchInterval(d),
+ queryFn: async () => {
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/bulk-document-download/${done!.taskId}`,
+ );
+ const body = await parseBody(res);
+ if (!res.ok || !body) {
+ throw new Error("Couldn’t check the download status.");
+ }
+ return body as unknown as BulkDownloadStatus;
+ },
+ });
+
+ const selection: DocumentSelection | undefined = selecting
+ ? {
+ selectedIds,
+ onToggle: (id) =>
+ setSelectedIds((prev) => {
+ const next = new Set(prev);
+ if (next.has(id)) next.delete(id);
+ else next.add(id);
+ return next;
+ }),
+ onSetMany: (ids, on) =>
+ setSelectedIds((prev) => {
+ const next = new Set(prev);
+ for (const id of ids) {
+ if (on) next.add(id);
+ else next.delete(id);
+ }
+ return next;
+ }),
+ }
+ : undefined;
+
+ const overCap = selectedIds.size > MAX_BULK_DOWNLOAD_PROPERTIES;
+
+ return (
+
+ {/* Delivery / status card */}
+ {done && (
+
setDone(null)}
+ />
+ )}
+
+ {/* Bulk-download control bar */}
+ {!selecting ? (
+
+
setSelecting(true)}
+ className="inline-flex items-center gap-2 h-9 px-3.5 rounded-lg border border-brandblue/20 bg-white text-sm font-medium text-brandblue hover:border-brandblue/40 hover:bg-brandlightblue/10 transition-colors"
+ >
+
+ Bulk download
+
+
+ ) : (
+
+
+ {selectedIds.size} selected
+
+
+ Tick properties, or use the header box to select the page (then “select
+ all across pages”).
+
+ {overCap && (
+
+ Over the {MAX_BULK_DOWNLOAD_PROPERTIES} limit — narrow your selection.
+
+ )}
+ {trigger.isError && (
+
{trigger.error.message}
+ )}
+
+ {
+ setSelecting(false);
+ setSelectedIds(new Set());
+ trigger.reset();
+ }}
+ className="inline-flex items-center gap-1.5 h-9 px-3 rounded-lg border border-gray-200 bg-white text-sm font-medium text-gray-600 hover:bg-gray-50 transition-colors"
+ >
+
+ Cancel
+
+ trigger.mutate()}
+ disabled={!built.ok || trigger.isLoading}
+ className="inline-flex items-center gap-2 h-9 px-3.5 rounded-lg bg-brandblue text-sm font-semibold text-white hover:bg-brandblue/90 disabled:opacity-40 transition-colors"
+ >
+ {trigger.isLoading ? (
+
+ ) : (
+
+ )}
+ {trigger.isLoading ? "Starting…" : "Download selected"}
+
+
+
+ )}
+
+
+
+ );
+}
+
+function DeliveryCard({
+ status,
+ isError,
+ onDismiss,
+}: {
+ status: BulkDownloadStatus | undefined;
+ isError: boolean;
+ onDismiss: () => void;
+}) {
+ const [showSkipped, setShowSkipped] = useState(false);
+ const state = status?.state ?? "preparing";
+
+ // Completed, but the link couldn't be surfaced in-app (unparseable outputs).
+ // The worker still emails it — send the user there rather than hang.
+ if (state === "ready" && !status?.delivery) {
+ return (
+
+
+
+
Your download is ready
+
+ We’ve emailed you the link — it’s valid for about 60 minutes.
+
+
+
+ Dismiss
+
+
+ );
+ }
+
+ if (state === "ready" && status?.delivery) {
+ const { presignedUrl, included, skipped } = status.delivery;
+ return (
+
+
+
+
+
Your download is ready
+
+ {included} {included === 1 ? "document" : "documents"} included
+ {skipped.length > 0 && ` · ${skipped.length} skipped`}. We’ve also emailed
+ the link — it’s valid for about 60 minutes.
+
+
+
+
+ Download ZIP
+
+
+ {skipped.length > 0 && (
+
+
setShowSkipped((s) => !s)}
+ className="text-[12.5px] font-semibold text-brandmidblue hover:underline"
+ >
+ {showSkipped ? "Hide" : "Show"} {skipped.length} skipped
+
+ {showSkipped && (
+
+ {skipped.map((s, i) => (
+
+ {s.landlord_property_id} — {s.reason}
+
+ ))}
+
+ )}
+
+ )}
+
+ );
+ }
+
+ if (state === "failed" || isError) {
+ return (
+
+
+
+
+ We couldn’t build this download
+
+
+ The selection may contain no documents. Try a different selection.
+
+
+
+ Dismiss
+
+
+ );
+ }
+
+ return (
+
+
+
+
+ Your download is being prepared — we’ll email you a link
+
+
+ You can leave this page; the link will be in your inbox, and it’ll appear here
+ if you stay.
+
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentTable.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentTable.tsx
index cd09460e..ec50d043 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentTable.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/DocumentTable.tsx
@@ -10,6 +10,7 @@ import {
flexRender,
type SortingState,
type PaginationState,
+ type ColumnDef,
} from "@tanstack/react-table";
import {
Table,
@@ -34,6 +35,18 @@ import type { ClassifiedDeal, DocStatusMap, PortfolioCapabilityType, ApprovalsBy
type RetroAssessmentFilter = "all" | "none" | "partial" | "complete";
type InstallStatusFilter = "all" | "none" | "hasDocs" | "partial" | "complete";
+/**
+ * Row-selection wiring for bulk document download. When present, the table
+ * shows a tick column; select-all operates over every filtered row (all pages),
+ * not just the visible page. Rows without a landlord property id are un-tickable
+ * — documents are matched by landlord property id, so there is nothing to zip.
+ */
+export interface DocumentSelection {
+ selectedIds: Set;
+ onToggle: (landlordPropertyId: string) => void;
+ onSetMany: (landlordPropertyIds: string[], selected: boolean) => void;
+}
+
interface DocumentTableProps {
data: ClassifiedDeal[];
onOpenDrawer: (dealId: string, uprn: string | null, landlordPropertyId: string | null, dealname: string | null, batch: string | null, batchDescription: string | null) => void;
@@ -41,6 +54,7 @@ interface DocumentTableProps {
portfolioId: string;
userCapability: PortfolioCapabilityType;
approvalsByDeal?: ApprovalsByDeal;
+ selection?: DocumentSelection;
}
function escapeCell(value: unknown): string {
@@ -54,7 +68,7 @@ function escapeCell(value: unknown): string {
: str;
}
-export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfolioId, userCapability, approvalsByDeal }: DocumentTableProps) {
+export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfolioId, userCapability, approvalsByDeal, selection }: DocumentTableProps) {
const [globalFilter, setGlobalFilter] = useState("");
const [retroAssessmentFilter, setRetroAssessmentFilter] = useState("all");
const [installStatusFilter, setInstallStatusFilter] = useState("all");
@@ -87,7 +101,7 @@ export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfo
});
}, [data, retroAssessmentFilter, installStatusFilter, docStatusMap]);
- const columns = useMemo(
+ const baseColumns = useMemo(
() => createDocumentTableColumns(
onOpenDrawer,
docStatusMap,
@@ -96,6 +110,60 @@ export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfo
[onOpenDrawer, docStatusMap, userCapability],
);
+ // Prepend a tick column when in selection mode. Recomputed when `selection`
+ // changes (a fresh Set per toggle) so checkbox state stays live.
+ const columns: ColumnDef[] = useMemo(() => {
+ if (!selection) return baseColumns;
+ const selectColumn: ColumnDef = {
+ id: "select",
+ enableSorting: false,
+ enableGlobalFilter: false,
+ header: ({ table }) => {
+ // Header ticks the current page; the banner below offers all pages.
+ const pageIds = table
+ .getRowModel()
+ .rows.map((r) => r.original.landlordPropertyId)
+ .filter((id): id is string => !!id);
+ const allSelected =
+ pageIds.length > 0 && pageIds.every((id) => selection.selectedIds.has(id));
+ const someSelected = pageIds.some((id) => selection.selectedIds.has(id));
+ return (
+ {
+ if (el) el.indeterminate = someSelected && !allSelected;
+ }}
+ onChange={() => selection.onSetMany(pageIds, !allSelected)}
+ className="h-4 w-4 accent-brandblue align-middle"
+ />
+ );
+ },
+ cell: ({ row }) => {
+ const id = row.original.landlordPropertyId;
+ if (!id) {
+ return (
+
+ );
+ }
+ return (
+ selection.onToggle(id)}
+ className="h-4 w-4 accent-brandblue align-middle"
+ />
+ );
+ },
+ };
+ return [selectColumn, ...baseColumns];
+ }, [baseColumns, selection]);
+
const table = useReactTable({
data: filteredData,
columns,
@@ -151,6 +219,31 @@ export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfo
const currentPage = table.getState().pagination.pageIndex + 1;
const totalFiltered = table.getFilteredRowModel().rows.length;
+ // "Select all across pages" banner: shown when the whole current page is
+ // ticked and there are more filtered rows than fit on it (Gmail-style).
+ const pageSelectableIds = selection
+ ? table
+ .getRowModel()
+ .rows.map((r) => r.original.landlordPropertyId)
+ .filter((id): id is string => !!id)
+ : [];
+ const filteredSelectableIds = selection
+ ? table
+ .getFilteredRowModel()
+ .rows.map((r) => r.original.landlordPropertyId)
+ .filter((id): id is string => !!id)
+ : [];
+ const pageFullySelected =
+ pageSelectableIds.length > 0 &&
+ pageSelectableIds.every((id) => selection!.selectedIds.has(id));
+ const allFilteredSelected =
+ filteredSelectableIds.length > 0 &&
+ filteredSelectableIds.every((id) => selection!.selectedIds.has(id));
+ const showSelectAllBanner =
+ !!selection &&
+ pageFullySelected &&
+ filteredSelectableIds.length > pageSelectableIds.length;
+
const retroAssessmentLabel: Record = {
all: "All retrofit statuses",
none: "No Retrofit Docs",
@@ -248,6 +341,40 @@ export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfo
propert{totalFiltered === 1 ? "y" : "ies"}
+ {/* Select-all-across-pages banner */}
+ {showSelectAllBanner && (
+
+ {allFilteredSelected ? (
+ <>
+
+ All {filteredSelectableIds.length} {" "}
+ matching propert{filteredSelectableIds.length === 1 ? "y is" : "ies are"}{" "}
+ selected.
+
+ selection!.onSetMany(filteredSelectableIds, false)}
+ className="font-semibold underline hover:text-brandblue/80"
+ >
+ Clear selection
+
+ >
+ ) : (
+ <>
+
+ All {pageSelectableIds.length} on this
+ page selected.
+
+ selection!.onSetMany(filteredSelectableIds, true)}
+ className="font-semibold underline hover:text-brandblue/80"
+ >
+ Select all {filteredSelectableIds.length} across pages
+
+ >
+ )}
+
+ )}
+
{/* Table */}
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/LiveTracker.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/LiveTracker.tsx
index b8a67a3a..1318ba79 100644
Binary files a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/LiveTracker.tsx and b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/LiveTracker.tsx differ
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTable.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTable.tsx
index d1e07c96..6c0e4ddf 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTable.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTable.tsx
@@ -67,7 +67,15 @@ const COLUMN_LABELS: Record
= {
coordinationComments: "Coordination Comments",
dampAndMouldGrowth: "Damp and Mould Growth",
dampMouldAndRepairComments: "Damp, Mould and Repair Comments",
- domnaSurveyRequested: "Domna Survey Requested"
+ domnaSurveyRequested: "Domna Survey Requested",
+ planningAuthority: "Planning Authority",
+ designatedArea: "Designated Area",
+ article4PdRights: "Article 4 PD Rights",
+ listedBuilding: "Listed Building",
+ designConstraints: "Design Constraints",
+ planningComments: "Planning Comments",
+ planningStatus: "Planning Status",
+ planningSuggestedApproach: "Planning Suggested Approach",
};
type DocFilter = "all" | "has_docs" | "incomplete" | "none";
@@ -114,6 +122,14 @@ export default function PropertyTable({ data, onOpenDrawer, portfolioId = "", sh
dampAndMouldGrowth: false,
dampMouldAndRepairComments: false,
domnaSurveyRequested: false,
+ planningAuthority: false,
+ designatedArea: false,
+ article4PdRights: false,
+ listedBuilding: false,
+ designConstraints: false,
+ planningComments: false,
+ planningStatus: false,
+ planningSuggestedApproach: false,
});
// Pre-filter by stage, doc status, and removal status before TanStack gets it
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTableColumns.tsx b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTableColumns.tsx
index aa0157a2..ee43edd5 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTableColumns.tsx
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/PropertyTableColumns.tsx
@@ -439,6 +439,102 @@ export function createPropertyTableColumns(
},
},
+ // ── Planning authority ───────────────────────────────────────────────
+ {
+ accessorKey: "planningAuthority",
+ id: "planningAuthority",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.planningAuthority ?? — }
+
+ ),
+ },
+
+ // ── Designated area ──────────────────────────────────────────────────
+ {
+ accessorKey: "designatedArea",
+ id: "designatedArea",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.designatedArea ?? — }
+
+ ),
+ },
+
+ // ── Article 4 PD rights ──────────────────────────────────────────────
+ {
+ accessorKey: "article4PdRights",
+ id: "article4PdRights",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.article4PdRights ?? — }
+
+ ),
+ },
+
+ // ── Listed building ──────────────────────────────────────────────────
+ {
+ accessorKey: "listedBuilding",
+ id: "listedBuilding",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.listedBuilding ?? — }
+
+ ),
+ },
+
+ // ── Design constraints ───────────────────────────────────────────────
+ {
+ accessorKey: "designConstraints",
+ id: "designConstraints",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.designConstraints ?? — }
+
+ ),
+ },
+
+ // ── Planning comments ────────────────────────────────────────────────
+ {
+ accessorKey: "planningComments",
+ id: "planningComments",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.planningComments ?? — }
+
+ ),
+ },
+
+ // ── Planning status ──────────────────────────────────────────────────
+ {
+ accessorKey: "planningStatus",
+ id: "planningStatus",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.planningStatus ?? — }
+
+ ),
+ },
+
+ // ── Planning suggested approach ──────────────────────────────────────
+ {
+ accessorKey: "planningSuggestedApproach",
+ id: "planningSuggestedApproach",
+ header: ({ column }) => ,
+ cell: ({ row }) => (
+
+ {row.original.planningSuggestedApproach ?? — }
+
+ ),
+ },
+
];
if (showDocuments) {
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/dealQuery.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/dealQuery.ts
index 68ce00ac..01cc259d 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/dealQuery.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/dealQuery.ts
@@ -73,6 +73,14 @@ export function mapDbRowToHubspotDeal(row: DealRow): HubspotDeal {
domnaSurveyDate: d.domnaSurveyDate,
batch: d.batch,
batchDescription: d.batchDescription,
+ planningAuthority: d.planningAuthority,
+ designatedArea: d.designatedArea,
+ article4PdRights: d.article4PdRights,
+ listedBuilding: d.listedBuilding,
+ designConstraints: d.designConstraints,
+ planningComments: d.planningComments,
+ planningStatus: d.planningStatus,
+ planningSuggestedApproach: d.planningSuggestedApproach,
createdAt: d.createdAt,
updatedAt: d.updatedAt,
};
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/docStatus.test.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/docStatus.test.ts
index 32d1671e..cd2c1d08 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/docStatus.test.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/docStatus.test.ts
@@ -60,6 +60,14 @@ function makeDeal(overrides: Partial = {}): HubspotDeal {
domnaSurveyDate: null,
batch: null,
batchDescription: null,
+ planningAuthority: null,
+ designatedArea: null,
+ article4PdRights: null,
+ listedBuilding: null,
+ designConstraints: null,
+ planningComments: null,
+ planningStatus: null,
+ planningSuggestedApproach: null,
coordinationComments: null,
domnasurveyRequired: null,
createdAt: new Date(),
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/measureFilters.test.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/measureFilters.test.ts
index 6a30d703..3f7fec46 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/measureFilters.test.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/measureFilters.test.ts
@@ -59,6 +59,14 @@ function makeDeal(overrides: Partial = {}): ClassifiedDeal {
domnaSurveyDate: null,
batch: null,
batchDescription: null,
+ planningAuthority: null,
+ designatedArea: null,
+ article4PdRights: null,
+ listedBuilding: null,
+ designConstraints: null,
+ planningComments: null,
+ planningStatus: null,
+ planningSuggestedApproach: null,
coordinationComments: null,
domnasurveyRequired: null,
createdAt: new Date(),
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.test.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.test.ts
index 91501665..b0ee7179 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.test.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.test.ts
@@ -59,6 +59,14 @@ function makeDeal(overrides: Partial = {}): HubspotDeal {
domnaSurveyDate: null,
batch: null,
batchDescription: null,
+ planningAuthority: null,
+ designatedArea: null,
+ article4PdRights: null,
+ listedBuilding: null,
+ designConstraints: null,
+ planningComments: null,
+ planningStatus: null,
+ planningSuggestedApproach: null,
coordinationComments: null,
domnasurveyRequired: null,
createdAt: new Date(),
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.ts
index 1b29caab..21296c0c 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyCsv.ts
@@ -30,6 +30,14 @@ export const PROPERTY_CSV_FIELDS: PropertyCsvField[] = [
{ key: "dampMouldFlag", label: "Damp and Mould Growth" },
{ key: "dampMouldAndRepairComments", label: "Damp Mould and Repair Comments" },
{ key: "domnasurveyRequired", label: "Domna Survey Required" },
+ { key: "planningAuthority", label: "Planning Authority" },
+ { key: "designatedArea", label: "Designated Area" },
+ { key: "article4PdRights", label: "Article 4 PD Rights" },
+ { key: "listedBuilding", label: "Listed Building" },
+ { key: "designConstraints", label: "Design Constraints" },
+ { key: "planningComments", label: "Planning Comments" },
+ { key: "planningStatus", label: "Planning Status" },
+ { key: "planningSuggestedApproach", label: "Planning Suggested Approach" },
];
export function escapeCsvCell(value: unknown): string {
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/transforms.test.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/transforms.test.ts
index ad7bf045..eae27870 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/transforms.test.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/transforms.test.ts
@@ -66,6 +66,14 @@ function makeDeal(overrides: Partial = {}): HubspotDeal {
domnaSurveyDate: null,
batch: null,
batchDescription: null,
+ planningAuthority: null,
+ designatedArea: null,
+ article4PdRights: null,
+ listedBuilding: null,
+ designConstraints: null,
+ planningComments: null,
+ planningStatus: null,
+ planningSuggestedApproach: null,
coordinationComments: null,
domnasurveyRequired: null,
createdAt: new Date(),
diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/types.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/types.ts
index aa49fe25..b1501487 100644
--- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/types.ts
+++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/types.ts
@@ -71,6 +71,16 @@ export type HubspotDeal = {
batch: string | null;
batchDescription: string | null;
+ // ── Planning fields (issue: extra PM columns) ─────────────────────────
+ planningAuthority: string | null;
+ designatedArea: string | null;
+ article4PdRights: string | null;
+ listedBuilding: string | null;
+ designConstraints: string | null;
+ planningComments: string | null;
+ planningStatus: string | null;
+ planningSuggestedApproach: string | null;
+
createdAt: Date;
updatedAt: Date;
};
diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx
index 92c12eed..ed2080be 100644
--- a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx
+++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx
@@ -6,8 +6,10 @@ import {
SparklesIcon,
BuildingOfficeIcon,
ShieldCheckIcon,
+ ExclamationTriangleIcon,
} from "@heroicons/react/24/outline";
import { CheckCircleIcon, XCircleIcon } from "@heroicons/react/24/solid";
+import Link from "next/link";
import {
getPropertyMeta,
getConditionReport,
@@ -67,6 +69,43 @@ export default async function BuildingPassportHome(props: {
}) {
const params = await props.params;
const propertyMeta = await getPropertyMeta(params.propertyId);
+
+ // A property with no UPRN isn't matched to an Ordnance Survey address yet, so
+ // the whole UPRN-keyed passport (spatial data, installed measures, EPC) has
+ // nothing to show — and getSpatialData(BigInt(null)) would 500. Surface a
+ // clear "not matched" state and link back to the portfolio instead.
+ if (!propertyMeta.uprn) {
+ return (
+
+
+
+
+ Not matched to a UPRN yet
+
+
+ {propertyMeta.address ? (
+ <>
+ {propertyMeta.address} {" "}
+ hasn't{" "}
+ >
+ ) : (
+ "This property hasn't "
+ )}
+ been matched to an Ordnance Survey address, so its building passport
+ isn't available yet. Match it to a UPRN from the portfolio to
+ unlock the passport.
+
+
+ Back to portfolio
+
+
+
+ );
+ }
+
const conditionReport = await getConditionReport(params.propertyId);
const spatial = await getSpatialData(propertyMeta.uprn);
const installedMeasures = await getInstalledMeasuresByUprn(Number(propertyMeta.uprn));
diff --git a/src/app/portfolio/[slug]/components/BulkTagUploadModal.tsx b/src/app/portfolio/[slug]/components/BulkTagUploadModal.tsx
new file mode 100644
index 00000000..21e4ffed
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/BulkTagUploadModal.tsx
@@ -0,0 +1,324 @@
+"use client";
+
+import { useState } from "react";
+import { useMutation } from "@tanstack/react-query";
+import * as XLSX from "xlsx";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@/app/shadcn_components/ui/dialog";
+import { Button } from "@/app/shadcn_components/ui/button";
+import { parseTagIdentifierRows, IdentifierKey } from "@/lib/tags/bulkAssign";
+import { Tag, useInvalidateTagSurfaces, usePortfolioTags } from "./useTags";
+import { TagChip } from "./TagChip";
+
+interface Parsed {
+ key: IdentifierKey;
+ identifiers: string[];
+}
+
+interface AssignSummary {
+ matchedPropertyCount: number;
+ taggedCount: number;
+ alreadyTaggedCount: number;
+ unmatchedCount: number;
+ unmatchedIdentifiers: string[];
+}
+
+const KEY_LABEL: Record = {
+ landlord_property_id: "Property Ref (landlord id)",
+ uprn: "UPRN",
+};
+
+/** Download a one-column CSV template the user can fill in and re-upload. */
+function downloadTemplate(key: IdentifierKey) {
+ const example =
+ key === "uprn"
+ ? ["100012345678", "100012345679"]
+ : ["PROP-0001", "PROP-0002"];
+ const csv = [key, ...example].join("\n") + "\n";
+ const url = URL.createObjectURL(new Blob([csv], { type: "text/csv;charset=utf-8;" }));
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `tag-assignment-template-${key}.csv`;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+}
+
+/**
+ * Bulk tag assignment upload (ADR-0013): reads a small CSV/Excel of identifiers
+ * client-side, parses it with the shared pure parser, lets the user pick a
+ * target Tag, then POSTs {mode:"identifiers"} and renders the match summary.
+ * No FastAPI pipeline — the file matches existing identifiers to Properties.
+ */
+export function BulkTagUploadModal({
+ portfolioId,
+ open,
+ onOpenChange,
+}: {
+ portfolioId: string;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) {
+ const { data: tags = [] } = usePortfolioTags(portfolioId);
+ const invalidate = useInvalidateTagSurfaces(portfolioId);
+
+ const [fileName, setFileName] = useState(null);
+ const [parsed, setParsed] = useState(null);
+ const [parseError, setParseError] = useState(null);
+ const [targetTag, setTargetTag] = useState(null);
+ const [summary, setSummary] = useState(null);
+
+ function reset() {
+ setFileName(null);
+ setParsed(null);
+ setParseError(null);
+ setTargetTag(null);
+ setSummary(null);
+ assign.reset();
+ }
+
+ async function onFile(file: File) {
+ setParseError(null);
+ setParsed(null);
+ setSummary(null);
+ setFileName(file.name);
+ try {
+ const buf = await file.arrayBuffer();
+ const wb = XLSX.read(buf, { type: "array" });
+ const sheet = wb.Sheets[wb.SheetNames[0]];
+ const rows = XLSX.utils.sheet_to_json(sheet, { header: 1 }) as (
+ | string
+ | number
+ | null
+ )[][];
+ const result = parseTagIdentifierRows(rows);
+ if (!result.ok) {
+ setParseError(result.error);
+ return;
+ }
+ setParsed({ key: result.key, identifiers: result.identifiers });
+ } catch {
+ setParseError("Couldn't read that file — is it a valid CSV or Excel?");
+ }
+ }
+
+ const assign = useMutation({
+ mutationFn: async () => {
+ if (!parsed || !targetTag) throw new Error("Pick a file and a tag first");
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/tags/${targetTag.id}/assignments`,
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ mode: "identifiers",
+ key: parsed.key,
+ identifiers: parsed.identifiers,
+ }),
+ },
+ );
+ const body = await res.json();
+ if (!res.ok) throw new Error(body.error ?? "Couldn't assign the tag");
+ return body;
+ },
+ onSuccess: (data) => {
+ setSummary(data);
+ invalidate();
+ },
+ });
+
+ return (
+ {
+ if (!o) reset();
+ onOpenChange(o);
+ }}
+ >
+
+
+ Assign a tag from a file
+
+ Upload a CSV or Excel file with a{" "}
+ landlord_property_id or{" "}
+ uprn column. We'll match
+ those to properties in this portfolio and apply the tag you pick.
+
+
+
+ {summary ? (
+
+
+
+ Tagged {summary.taggedCount.toLocaleString()}{" "}
+ propert{summary.taggedCount === 1 ? "y" : "ies"}
+ {targetTag ? (
+ <>
+ {" "}
+ with{" "}
+
+ >
+ ) : null}
+ .
+
+
+ {summary.matchedPropertyCount.toLocaleString()} matched the file
+ {summary.alreadyTaggedCount > 0 && (
+
+ {summary.alreadyTaggedCount.toLocaleString()} already had the tag
+
+ )}
+ {summary.unmatchedCount > 0 && (
+
+ {summary.unmatchedCount.toLocaleString()} identifier
+ {summary.unmatchedCount === 1 ? "" : "s"} matched no property
+
+ )}
+
+
+ {summary.unmatchedIdentifiers.length > 0 && (
+
+
+ Show unmatched identifiers
+
+
+ {summary.unmatchedIdentifiers.join(", ")}
+ {summary.unmatchedCount > summary.unmatchedIdentifiers.length &&
+ " …"}
+
+
+ )}
+
+ ) : (
+
+
+
+ {fileName ?? "Choose a CSV or Excel file"}
+
+
+ First row must be a header
+
+ {
+ const f = e.target.files?.[0];
+ if (f) onFile(f);
+ }}
+ />
+
+
+
+ Need a starting point? Download a template for{" "}
+ downloadTemplate("landlord_property_id")}
+ className="font-semibold text-brandmidblue hover:underline"
+ >
+ Property Ref
+ {" "}
+ or{" "}
+ downloadTemplate("uprn")}
+ className="font-semibold text-brandmidblue hover:underline"
+ >
+ UPRN
+
+ .
+
+
+ {parseError && (
+
{parseError}
+ )}
+
+ {parsed && (
+
+
+ Found{" "}
+
+ {parsed.identifiers.length.toLocaleString()}
+ {" "}
+ identifiers, matching on{" "}
+
+ {KEY_LABEL[parsed.key]}
+
+ .
+
+
+
+ Apply which tag?
+
+ {tags.length === 0 ? (
+
+ No tags yet —{" "}
+
+ create one first
+
+ .
+
+ ) : (
+
+ {tags.map((t) => (
+ setTargetTag(t)}
+ className={`rounded-full transition ${
+ targetTag?.id === t.id
+ ? "ring-2 ring-brandmidblue ring-offset-1"
+ : "opacity-70 hover:opacity-100"
+ }`}
+ >
+
+
+ ))}
+
+ )}
+
+
+ )}
+
+ {assign.isError && (
+
{assign.error.message}
+ )}
+
+ )}
+
+
+ {summary ? (
+ <>
+
+ Assign another
+
+ onOpenChange(false)}>Done
+ >
+ ) : (
+ <>
+ onOpenChange(false)}>
+ Cancel
+
+ assign.mutate()}
+ >
+ {assign.isLoading ? "Assigning…" : "Assign tag"}
+
+ >
+ )}
+
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/MatchAddress.tsx b/src/app/portfolio/[slug]/components/MatchAddress.tsx
new file mode 100644
index 00000000..549420bd
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/MatchAddress.tsx
@@ -0,0 +1,242 @@
+"use client";
+
+import { useState } from "react";
+import { useRouter } from "next/navigation";
+import {
+ MagnifyingGlassIcon,
+ CheckCircleIcon,
+} from "@heroicons/react/24/outline";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@/app/shadcn_components/ui/dialog";
+import { describeCandidate } from "@/lib/postcodeSearch/model";
+import {
+ searchAddresses,
+ useAssignUprn,
+ type SearchCandidate,
+} from "@/lib/properties/client";
+import type { UnmatchedProperty } from "@/lib/properties/unmatched";
+
+// Row action for an unmatched property: edit the address, confirm the postcode,
+// search Ordnance Survey, and pick from the RESIDENTIAL addresses in that
+// postcode. Picking assigns that candidate's UPRN — every candidate is a real
+// OS address, so this guarantees a valid, residential UPRN. On success the
+// property leaves the "Needs attention" tab (the page re-fetches).
+export default function MatchAddress({
+ property,
+ portfolioId,
+}: {
+ property: UnmatchedProperty;
+ portfolioId: string;
+}) {
+ const router = useRouter();
+ const [open, setOpen] = useState(false);
+ const [address, setAddress] = useState(property.address ?? "");
+ const [postcode, setPostcode] = useState(property.postcode ?? "");
+ // null = not searched yet; [] = searched, no residential matches.
+ const [residential, setResidential] = useState(null);
+ const [selected, setSelected] = useState(null);
+ const [source, setSource] = useState<"cache" | "live" | null>(null);
+ const [searching, setSearching] = useState(false);
+ const [searchError, setSearchError] = useState(null);
+
+ const assign = useAssignUprn(portfolioId, property.id);
+
+ async function runSearch() {
+ setSearching(true);
+ setSearchError(null);
+ setResidential(null);
+ setSelected(null);
+ try {
+ const result = await searchAddresses(portfolioId, postcode);
+ // Residential only — we never assign a non-residential UPRN.
+ setResidential(result.candidates.filter((c) => c.selectable));
+ setSource(result.source);
+ } catch (e) {
+ setSearchError(e instanceof Error ? e.message : "Search failed.");
+ } finally {
+ setSearching(false);
+ }
+ }
+
+ function onAssign() {
+ if (!selected) return;
+ assign.mutate(
+ {
+ uprn: selected.uprn,
+ address: selected.address,
+ postcode: selected.postcode,
+ userInputtedAddress: address.trim() || undefined,
+ userInputtedPostcode: postcode.trim() || undefined,
+ },
+ {
+ onSuccess: () => {
+ setOpen(false);
+ router.refresh();
+ },
+ },
+ );
+ }
+
+ return (
+ <>
+ setOpen(true)}
+ className="inline-flex items-center gap-1.5 rounded-lg border border-amber-300 bg-white px-3 py-1.5 text-xs font-semibold text-amber-800 transition-colors hover:bg-amber-100"
+ >
+
+ Find UPRN
+
+
+
+
+
+ Match to a UPRN
+
+ Confirm the postcode and pick the matching address. Only
+ residential addresses from Ordnance Survey are shown, so the UPRN
+ is always valid.
+
+
+
+
+
+
+ Address
+
+ setAddress(e.target.value)}
+ placeholder="e.g. 20 Brenchley Road"
+ className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-amber-400 focus:outline-none focus:ring-1 focus:ring-amber-400"
+ />
+
+
+
+
+ Postcode
+
+ setPostcode(e.target.value)}
+ placeholder="e.g. BR5 2TD"
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && postcode.trim() && !searching)
+ runSearch();
+ }}
+ className="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm uppercase focus:border-amber-400 focus:outline-none focus:ring-1 focus:ring-amber-400"
+ />
+
+
+
+ {searching ? "Searching…" : "Search"}
+
+
+
+ {searchError &&
{searchError}
}
+
+ {residential && (
+
+
+
+ Residential addresses
+
+ {source === "cache" && (
+
+ from cache
+
+ )}
+
+
+ {residential.length === 0 ? (
+
+ No residential addresses found for that postcode.
+
+ ) : (
+
+ {residential.map((c) => {
+ const { label } = describeCandidate(c);
+ const disabled = c.alreadyInPortfolio;
+ const isSelected = selected?.uprn === c.uprn;
+ return (
+
+ setSelected(c)}
+ className={`flex w-full items-start gap-2 px-3 py-2 text-left text-sm transition-colors ${
+ disabled
+ ? "cursor-not-allowed text-gray-400"
+ : isSelected
+ ? "bg-amber-50"
+ : "hover:bg-gray-50"
+ }`}
+ >
+
+
+
+ {c.address}
+
+
+ UPRN {c.uprn} · {label}
+ {c.alreadyInPortfolio
+ ? " · already in portfolio"
+ : ""}
+
+
+
+
+ );
+ })}
+
+ )}
+
+
+ )}
+
+
+
+ {assign.error && (
+
+ {assign.error.message}
+
+ )}
+ setOpen(false)}
+ className="rounded-lg px-4 py-2 text-sm font-semibold text-gray-600 hover:bg-gray-100"
+ >
+ Cancel
+
+
+ {assign.isPending ? "Assigning…" : "Assign UPRN"}
+
+
+
+
+ >
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/PortfolioTabs.tsx b/src/app/portfolio/[slug]/components/PortfolioTabs.tsx
new file mode 100644
index 00000000..887fee92
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/PortfolioTabs.tsx
@@ -0,0 +1,77 @@
+"use client";
+
+import { useState } from "react";
+import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
+
+// Two-tab shell for the portfolio landing view: the main properties table, and
+// a "Needs attention" tab for properties that aren't matched to a UPRN yet.
+// Both panels stay mounted (hidden with CSS) so the table keeps its filter /
+// pagination state when the user flicks between tabs.
+export default function PortfolioTabs({
+ needsAttentionCount,
+ properties,
+ needsAttention,
+}: {
+ needsAttentionCount: number;
+ properties: React.ReactNode;
+ needsAttention: React.ReactNode;
+}) {
+ const [tab, setTab] = useState<"properties" | "needs-attention">("properties");
+
+ // Nothing unmatched → no tab strip at all, just the properties table.
+ if (needsAttentionCount === 0) return <>{properties}>;
+
+ return (
+
+
+ setTab("properties")}
+ >
+ Properties
+
+ setTab("needs-attention")}
+ >
+
+ Needs attention
+ {needsAttentionCount > 0 && (
+
+ {needsAttentionCount}
+
+ )}
+
+
+
+
{properties}
+
+ {needsAttention}
+
+
+ );
+}
+
+function TabButton({
+ active,
+ onClick,
+ children,
+}: {
+ active: boolean;
+ onClick: () => void;
+ children: React.ReactNode;
+}) {
+ return (
+
+ {children}
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/PropertyFilters.tsx b/src/app/portfolio/[slug]/components/PropertyFilters.tsx
index 7add0920..f8df4b12 100644
--- a/src/app/portfolio/[slug]/components/PropertyFilters.tsx
+++ b/src/app/portfolio/[slug]/components/PropertyFilters.tsx
@@ -3,6 +3,8 @@
import React, { useState, useRef, useEffect } from "react";
import { X, Plus, ChevronDown, Check } from "lucide-react";
import { getEpcColorClass } from "@/app/utils";
+import { tagDotColour } from "@/lib/tags/colour";
+import { Tag, usePortfolioTags } from "./useTags";
import {
FilterGroups,
FilterGroup,
@@ -10,13 +12,14 @@ import {
FilterField,
FilterOperator,
DatePreset,
- EnumOption,
PROPERTY_TYPE_OPTIONS,
BUILT_FORM_OPTIONS,
- TENURE_OPTIONS,
YEAR_BUILT_OPTIONS,
MAINFUEL_OPTIONS,
PROVENANCE_OPTIONS,
+ WALL_TYPE_OPTIONS,
+ ROOF_TYPE_OPTIONS,
+ HEATING_SYSTEM_OPTIONS,
} from "@/app/utils/propertyFilters";
/* -----------------------------------------------------------------------
@@ -32,14 +35,20 @@ const FIELD_OPTIONS: { value: FilterField; label: string }[] = [
{ value: "epcExpiryDate", label: "EPC Expiry Date" },
{ value: "propertyType", label: "Property Type" },
{ value: "builtForm", label: "Built Form" },
- { value: "tenure", label: "Tenure" },
- { value: "yearBuilt", label: "Year Built" },
+ { value: "yearBuilt", label: "Construction Age" },
{ value: "provenance", label: "Provenance" },
{ value: "floorArea", label: "Floor Area (m²)" },
{ value: "co2Emissions", label: "CO₂ Emissions (kg/m²/yr)" },
{ value: "mainfuel", label: "Main Fuel" },
+ { value: "wallType", label: "Wall Type" },
+ { value: "roofType", label: "Roof Type" },
+ { value: "heatingSystem", label: "Heating System" },
+ { value: "tags", label: "Tags" },
];
+/** The synthetic "no tags" bucket the server SQL recognises (ADR-0013). */
+const UNTAGGED_VALUE = "__untagged__";
+
const EPC_OPERATOR_OPTIONS: { value: FilterOperator; label: string }[] = [
{ value: "epc_less_than", label: "is worse than" },
{ value: "equals", label: "equals" },
@@ -71,13 +80,18 @@ const NUM_OPERATOR_OPTIONS: { value: FilterOperator; label: string }[] = [
{ value: "num_equals", label: "= (equals)" },
];
-const ENUM_FIELD_OPTIONS: Record = {
- propertyType: PROPERTY_TYPE_OPTIONS,
- builtForm: BUILT_FORM_OPTIONS,
- tenure: TENURE_OPTIONS,
- yearBuilt: YEAR_BUILT_OPTIONS,
- provenance: PROVENANCE_OPTIONS,
- mainfuel: MAINFUEL_OPTIONS,
+// Options need only a `label` for the dropdown: the exact-enum fields carry
+// EnumOption[] (dbValues used server-side), the free-text descriptor fields carry
+// DescriptorBucket[] (needles used server-side). Both satisfy `{ label }`.
+const ENUM_FIELD_OPTIONS: Record = {
+ propertyType: PROPERTY_TYPE_OPTIONS,
+ builtForm: BUILT_FORM_OPTIONS,
+ yearBuilt: YEAR_BUILT_OPTIONS,
+ provenance: PROVENANCE_OPTIONS,
+ mainfuel: MAINFUEL_OPTIONS,
+ wallType: WALL_TYPE_OPTIONS,
+ roofType: ROOF_TYPE_OPTIONS,
+ heatingSystem: HEATING_SYSTEM_OPTIONS,
};
/* -----------------------------------------------------------------------
@@ -95,10 +109,14 @@ function isNumericField(field: FilterField) {
return field === "floorArea" || field === "co2Emissions";
}
+function isTagField(field: FilterField) {
+ return field === "tags";
+}
+
function operatorsForField(field: FilterField): { value: FilterOperator; label: string }[] {
if (isEpcField(field)) return EPC_OPERATOR_OPTIONS;
if (field === "epcExpiryDate") return DATE_OPERATOR_OPTIONS;
- if (isEnumField(field)) return ENUM_OPERATOR_OPTIONS;
+ if (isEnumField(field) || isTagField(field)) return ENUM_OPERATOR_OPTIONS;
if (isNumericField(field)) return NUM_OPERATOR_OPTIONS;
return [];
}
@@ -107,9 +125,22 @@ function defaultOperatorForField(field: FilterField): FilterOperator {
return operatorsForField(field)[0]?.value ?? "equals";
}
-function conditionLabel(condition: PropertyFilter): string {
+function conditionLabel(condition: PropertyFilter, tags: Tag[] = []): string {
const fieldLabel = FIELD_OPTIONS.find((f) => f.value === condition.field)?.label ?? condition.field;
+ if (isTagField(condition.field)) {
+ try {
+ const values: string[] = JSON.parse(condition.value);
+ const byId = new Map(tags.map((t) => [t.id, t.name]));
+ const names = values.map((v) =>
+ v === UNTAGGED_VALUE ? "Untagged" : (byId.get(v) ?? "(deleted tag)"),
+ );
+ return `${fieldLabel} is one of: ${names.join(", ")}`;
+ } catch {
+ return `${fieldLabel} is one of: ${condition.value}`;
+ }
+ }
+
if (isEpcField(condition.field)) {
const opLabel = EPC_OPERATOR_OPTIONS.find((o) => o.value === condition.operator)?.label ?? condition.operator;
const value =
@@ -217,7 +248,7 @@ function EpcDropdown({
ref={buttonRef}
type="button"
onClick={openDropdown}
- className="w-full flex items-center justify-between rounded-md border border-gray-300 px-2 py-1.5 text-sm bg-white hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-black/10 transition"
+ className="w-full flex items-center justify-between rounded-md border border-gray-300 px-2 py-1.5 text-sm bg-white hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-brandblue/20 transition"
>
{selected.length === 0 ? (
@@ -256,7 +287,7 @@ function EpcDropdown({
{multi ? (
{isSelected && }
@@ -281,7 +312,7 @@ function EnumMultiDropdown({
selectedLabels,
onChange,
}: {
- options: EnumOption[];
+ options: { label: string }[];
selectedLabels: string[];
onChange: (labels: string[]) => void;
}) {
@@ -341,7 +372,7 @@ function EnumMultiDropdown({
ref={buttonRef}
type="button"
onClick={openDropdown}
- className="w-full flex items-center justify-between rounded-md border border-gray-300 px-2 py-1.5 text-sm bg-white hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-black/10 transition"
+ className="w-full flex items-center justify-between rounded-md border border-gray-300 px-2 py-1.5 text-sm bg-white hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-brandblue/20 transition"
>
{selectedLabels.length === 0 ? (
@@ -367,7 +398,134 @@ function EnumMultiDropdown({
{opt.label}
+ {isSelected && }
+
+
+ );
+ })}
+
+ )}
+
+ );
+}
+
+/* -----------------------------------------------------------------------
+ Tag Multi-Select Dropdown (dynamic per-portfolio, id-valued + Untagged)
+------------------------------------------------------------------------ */
+function TagMultiDropdown({
+ tags,
+ selected,
+ onChange,
+}: {
+ tags: Tag[];
+ selected: string[]; // tag ids and/or UNTAGGED_VALUE
+ onChange: (values: string[]) => void;
+}) {
+ const [open, setOpen] = useState(false);
+ const [dropdownStyle, setDropdownStyle] = useState({});
+ const ref = useRef(null);
+ const buttonRef = useRef(null);
+ const dropdownRef = useRef(null);
+
+ useEffect(() => {
+ function handleOutside(e: MouseEvent) {
+ if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);
+ }
+ function handleScroll(e: Event) {
+ if (dropdownRef.current && dropdownRef.current.contains(e.target as Node)) return;
+ setOpen(false);
+ }
+ if (open) {
+ document.addEventListener("mousedown", handleOutside);
+ window.addEventListener("scroll", handleScroll, true);
+ }
+ return () => {
+ document.removeEventListener("mousedown", handleOutside);
+ window.removeEventListener("scroll", handleScroll, true);
+ };
+ }, [open]);
+
+ function openDropdown() {
+ if (buttonRef.current) {
+ const rect = buttonRef.current.getBoundingClientRect();
+ setDropdownStyle({
+ position: "fixed",
+ top: rect.bottom + 4,
+ left: rect.left,
+ width: Math.max(rect.width, 220),
+ zIndex: 9999,
+ maxHeight: 280,
+ overflowY: "auto",
+ });
+ }
+ setOpen((o) => !o);
+ }
+
+ function toggle(value: string) {
+ onChange(
+ selected.includes(value)
+ ? selected.filter((v) => v !== value)
+ : [...selected, value],
+ );
+ }
+
+ const byId = new Map(tags.map((t) => [t.id, t]));
+ const summary = selected
+ .map((v) => (v === UNTAGGED_VALUE ? "Untagged" : byId.get(v)?.name))
+ .filter(Boolean)
+ .join(", ");
+
+ const options: { value: string; label: string; colour?: string }[] = [
+ ...tags.map((t) => ({ value: t.id, label: t.name, colour: t.colour })),
+ { value: UNTAGGED_VALUE, label: "Untagged" },
+ ];
+
+ return (
+
+
+
+ {selected.length === 0 ? (
+ Select tags…
+ ) : (
+ {summary}
+ )}
+
+
+
+
+ {open && (
+
+ {tags.length === 0 && (
+
+ No tags yet — filter by Untagged, or create tags in settings.
+
+ )}
+ {options.map((opt) => {
+ const isSelected = selected.includes(opt.value);
+ const untagged = opt.value === UNTAGGED_VALUE;
+ return (
+
toggle(opt.value)}
+ className={`w-full flex items-center gap-2.5 px-3 py-1.5 text-sm transition hover:bg-gray-50 text-left ${isSelected ? "bg-gray-50" : ""} ${untagged ? "mt-1 border-t border-dashed border-gray-200 pt-2" : ""}`}
+ >
+
+ {opt.label}
+
{isSelected && }
@@ -394,7 +552,7 @@ function NumberFilterInput({
return (
onChange(e.target.value)}
@@ -407,17 +565,19 @@ function NumberFilterInput({
------------------------------------------------------------------------ */
interface AddFilterFormProps {
targetGroupId: string | null; // null = new group
+ tags: Tag[];
onConfirm: (groupId: string | null, condition: PropertyFilter) => void;
onCancel: () => void;
}
-function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProps) {
+function AddFilterForm({ targetGroupId, tags, onConfirm, onCancel }: AddFilterFormProps) {
const [field, setField] = useState("currentEpc");
const [operator, setOperator] = useState("epc_less_than");
const [epcSelected, setEpcSelected] = useState([]);
const [dateValue, setDateValue] = useState("");
const [preset, setPreset] = useState("expired");
const [enumSelected, setEnumSelected] = useState([]);
+ const [tagSelected, setTagSelected] = useState([]);
const [numValue, setNumValue] = useState("");
function handleFieldChange(newField: FilterField) {
@@ -426,6 +586,7 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
setEpcSelected([]);
setDateValue("");
setEnumSelected([]);
+ setTagSelected([]);
setNumValue("");
}
@@ -436,6 +597,10 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
if (field === "epcExpiryDate") {
return operator === "date_preset" ? preset : dateValue;
}
+ if (isTagField(field)) {
+ // Value = JSON of tag ids (+ optional Untagged bucket); server resolves it.
+ return tagSelected.length > 0 ? JSON.stringify(tagSelected) : "";
+ }
if (isEnumField(field)) {
return enumSelected.length > 0 ? JSON.stringify(enumSelected) : "";
}
@@ -462,7 +627,7 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
}
const selectClass =
- "w-full rounded-md border border-gray-300 px-2 py-1.5 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-black/10";
+ "w-full rounded-md border border-gray-300 px-2 py-1.5 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-brandblue/20";
const enumOptions = isEnumField(field) ? ENUM_FIELD_OPTIONS[field] : [];
@@ -523,7 +688,7 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
{field === "epcExpiryDate" && operator !== "date_preset" && (
setDateValue(e.target.value)}
/>
@@ -537,6 +702,14 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
/>
)}
+ {isTagField(field) && (
+
+ )}
+
{isNumericField(field) && (
)}
@@ -548,7 +721,7 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
type="button"
onClick={handleConfirm}
disabled={!canConfirm()}
- className="flex-1 h-8 rounded-md bg-black text-xs font-medium text-white hover:bg-black/90 transition disabled:opacity-40 disabled:cursor-not-allowed"
+ className="flex-1 h-8 rounded-md bg-primary text-xs font-medium text-white hover:opacity-90 transition disabled:opacity-40 disabled:cursor-not-allowed"
>
Add
@@ -569,15 +742,17 @@ function AddFilterForm({ targetGroupId, onConfirm, onCancel }: AddFilterFormProp
------------------------------------------------------------------------ */
function ConditionRow({
condition,
+ tags,
onRemove,
}: {
condition: PropertyFilter;
+ tags: Tag[];
onRemove: () => void;
}) {
return (
- {conditionLabel(condition)}
+ {conditionLabel(condition, tags)}
void;
}) {
+ const { data: tags = [] } = usePortfolioTags(portfolioId);
// Draft state — only applied when user clicks Apply
const [draft, setDraft] = useState(filterGroups);
// "or" = new OR group, "and:" = AND condition into existing group, null = hidden
@@ -692,6 +870,7 @@ export default function PropertyFilters({
)}
removeCondition(group.id, condition.id)}
/>
@@ -701,6 +880,7 @@ export default function PropertyFilters({
{isAndTarget ? (
setAddMode(null)}
/>
@@ -723,6 +903,7 @@ export default function PropertyFilters({
{addMode === "or" ? (
setAddMode(null)}
/>
@@ -758,7 +939,7 @@ export default function PropertyFilters({
Apply
diff --git a/src/app/portfolio/[slug]/components/PropertyTable.tsx b/src/app/portfolio/[slug]/components/PropertyTable.tsx
index 21f644b9..92419d1a 100644
--- a/src/app/portfolio/[slug]/components/PropertyTable.tsx
+++ b/src/app/portfolio/[slug]/components/PropertyTable.tsx
@@ -18,14 +18,14 @@ import {
} from "@heroicons/react/24/outline";
import { useRouter } from "next/navigation";
import { HomeIcon } from "@heroicons/react/24/outline";
+import BulkUploadComingSoonModal from "@/app/components/portfolio/BulkUploadComingSoonModal";
import { sapToEpc } from "@/app/utils";
-import { columns } from "@/app/portfolio/[slug]/components/propertyTableColumns";
-import { PropertyWithRelations } from "@/app/db/schema/property";
import {
- TENURE_OPTIONS,
- MAINFUEL_OPTIONS,
- EnumOption,
-} from "@/app/utils/propertyFilters";
+ columns,
+ columnsWithoutSelect,
+} from "@/app/portfolio/[slug]/components/propertyTableColumns";
+import { PropertyWithRelations } from "@/app/db/schema/property";
+import { MAINFUEL_OPTIONS, EnumOption } from "@/app/utils/propertyFilters";
import {
OPTIONAL_COLUMN_IDS,
OPTIONAL_COLUMN_LABELS,
@@ -34,8 +34,12 @@ import {
VisibilityState,
Updater,
PaginationState,
+ RowSelectionState,
} from "@tanstack/react-table";
import { Tooltip } from "./Tooltip";
+import { TagsMenu } from "./TagsMenu";
+import { TagActionBar, TagMode } from "./TagActionBar";
+import { BulkTagUploadModal } from "./BulkTagUploadModal";
import {
DropdownMenu,
@@ -46,20 +50,19 @@ import {
DropdownMenuTrigger,
} from "@/app/shadcn_components/ui/dropdown-menu";
-import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
- DialogDescription,
- DialogFooter,
-} from "@/app/shadcn_components/ui/dialog";
-import { Button } from "@/app/shadcn_components/ui/button";
/* ----------------------------------------
Export helpers
----------------------------------------- */
-const EXPORT_LIMIT = 1000;
+const EXPORT_LIMIT = 6000;
+
+// Exactly one navy CTA is primary at a time (impeccable distill): Add properties
+// leads an empty portfolio, Run modelling leads a populated one; the other demotes
+// to the neutral toolbar-button style so the toolbar has a single focal action.
+const PRIMARY_CTA =
+ "flex items-center gap-1.5 h-8 px-3 rounded-lg bg-primary text-white text-xs font-semibold hover:opacity-90 transition";
+const SECONDARY_CTA =
+ "flex items-center gap-1.5 h-8 px-3 rounded-lg border border-slate-200 bg-white text-primary text-xs font-semibold hover:bg-slate-50 transition";
function resolveEnumLabel(
options: EnumOption[],
@@ -83,11 +86,13 @@ function exportToCsv(data: PropertyWithRelations[]) {
"Plan Cost (£)",
"Property Type",
"Built Form",
- "Tenure",
- "Year Built",
+ "Construction Age",
"Floor Area (m²)",
"CO₂ Emissions (kg/m²/yr)",
"Main Fuel",
+ "Wall Type",
+ "Roof Type",
+ "Heating System",
];
const rows = data.map((p) => {
@@ -117,11 +122,13 @@ function exportToCsv(data: PropertyWithRelations[]) {
p.totalRecommendationCost ? p.totalRecommendationCost.toFixed(2) : "",
p.propertyType ?? "",
p.builtForm ?? "",
- resolveEnumLabel(TENURE_OPTIONS, p.tenure),
p.yearBuilt ?? "",
p.totalFloorArea != null ? p.totalFloorArea.toFixed(1) : "",
p.co2Emissions != null ? p.co2Emissions.toFixed(1) : "",
resolveEnumLabel(MAINFUEL_OPTIONS, p.mainfuel),
+ p.wallType ?? "",
+ p.roofType ?? "",
+ p.heatingSystem ?? "",
];
});
@@ -232,43 +239,44 @@ function QuickFilterDropdown({
return (
-
- {label}
- {isActive ? (
- <>
+
+ {label}
+ {isActive ? (
: {committedValue}
- {
- e.stopPropagation();
- onClear();
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- e.stopPropagation();
- onClear();
- }
- }}
- className="ml-0.5 rounded-full hover:opacity-75"
- >
-
-
- >
- ) : (
-
+ ) : (
+
+ )}
+
+ {isActive && (
+ {
+ e.stopPropagation();
+ onClear();
+ }}
+ aria-label={`Clear ${label} filter`}
+ className="ml-1 rounded-full hover:opacity-75"
+ >
+
+
)}
-
+
{isOpen && (
@@ -308,6 +316,7 @@ export default function PropertyTable({
}) {
const router = useRouter();
const [sidebarOpen, setSidebarOpen] = useState(false);
+ const [bulkImportOpen, setBulkImportOpen] = useState(false);
const [committedAddress, setCommittedAddress] = useState("");
const [committedPostcode, setCommittedPostcode] = useState("");
@@ -315,12 +324,37 @@ export default function PropertyTable({
const [openFilter, setOpenFilter] = useState
(null);
const [filterGroups, setFilterGroups] = useState([]);
+ // Row selection for bulk tagging — keyed by property id (see DataTable getRowId).
+ const [rowSelection, setRowSelection] = useState({});
+ const selectedIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
+ // Deliberate "select all matching" escalation (whole set, not just loaded rows).
+ const [selectAllMatching, setSelectAllMatching] = useState(false);
+
+ const clearSelection = () => {
+ setRowSelection({});
+ setSelectAllMatching(false);
+ };
+ // Any manual checkbox change drops the all-matching escalation back to the
+ // explicit (possibly now-smaller) row selection.
+ const handleRowSelectionChange = (
+ updater: Updater,
+ ) => {
+ setSelectAllMatching(false);
+ setRowSelection(updater);
+ };
+
+ // Bulk-tag flows launched from the Tags menu: a contextual assign/remove mode,
+ // and the file-upload modal.
+ const [tagMode, setTagMode] = useState(null);
+ const [tagUploadOpen, setTagUploadOpen] = useState(false);
+
// Column visibility — lifted up from DataTable
const [columnVisibility, setColumnVisibility] = useState(
() => {
const init: VisibilityState = {};
OPTIONAL_COLUMN_IDS.forEach((id) => {
- init[id] = false;
+ // Tags ship visible by default (the headline of ADR-0013); the rest hidden.
+ init[id] = id === "tags";
});
return init;
},
@@ -406,8 +440,9 @@ export default function PropertyTable({
filterGroups: [],
});
const totalCount = allResponse?.total ?? 0;
+ const [modelNudgeDismissed, setModelNudgeDismissed] = useState(false);
- const DISPLAY_LIMIT = 1000;
+ const DISPLAY_LIMIT = 250;
const LOAD_MORE_SIZE = 100;
// ── Extra rows (lazy-loaded pages beyond the initial 1 000) ──────────────
@@ -432,6 +467,28 @@ export default function PropertyTable({
[queryData, extraRows],
);
+ // Properties with no default plan yet — the "not modelled" set. Counted from the
+ // loaded rows (cheap; avoids a hook per project convention): exact for a
+ // fully-loaded portfolio, a floor when more rows lazy-load beyond view.
+ const unmodelledInView = tableData.filter((p) => p.planId == null).length;
+
+ // Bulk-select scope: how many properties match the current view, whether every
+ // loaded row is ticked, and whether more match than are loaded (so "select all
+ // matching" is worth offering). matchingCount is filtered-total when a filter
+ // is active, else the whole portfolio.
+ const matchingCount = hasActiveFilters ? filteredTotal : totalCount;
+ const allLoadedSelected =
+ selectedIds.length > 0 && selectedIds.length === tableData.length;
+ const moreMatchThanLoaded = tableData.length < matchingCount;
+
+ // The not-modelled banner owns the Run-modelling CTA in this state, so the
+ // toolbar must NOT also show one — otherwise two identical navy buttons appear.
+ const showModelNudge =
+ !isLoading &&
+ totalCount > 0 &&
+ unmodelledInView > 0 &&
+ !modelNudgeDismissed;
+
// Controlled pagination (lifted from DataTable so we can detect the last page)
const [pagination, setPagination] = useState({
pageIndex: 0,
@@ -444,6 +501,8 @@ export default function PropertyTable({
prevFilterKeyRef.current = filterKey;
if (pagination.pageIndex !== 0)
setPagination((p) => ({ ...p, pageIndex: 0 }));
+ // The selection is filter-scoped — a changed filter invalidates it.
+ if (selectedIds.length > 0 || selectAllMatching) clearSelection();
}
const [isFetchingMore, setIsFetchingMore] = useState(false);
@@ -498,15 +557,35 @@ export default function PropertyTable({
if (isOnLastPage && hasMore) loadMore();
}, [isOnLastPage, hasMore, loadMore]);
- /* ----------------------------------------
- Delete preview state
- ----------------------------------------- */
- const [deletePropertyId, setDeletePropertyId] = useState(null);
- const [deletePreview, setDeletePreview] = useState<
- { table: string; count: number }[] | null
- >(null);
- const [previewLoading] = useState(false);
- const [previewError] = useState(null);
+ // Export fetches its own batch (up to EXPORT_LIMIT) for the current filters,
+ // independent of the on-screen page — the display fetch is deliberately small.
+ const [isExporting, setIsExporting] = useState(false);
+ const [exportError, setExportError] = useState(null);
+ const handleExport = useCallback(async () => {
+ if (isExporting) return;
+ setIsExporting(true);
+ setExportError(null);
+ try {
+ const res = await fetch("/api/properties", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ portfolioId,
+ filters: allFilterGroups,
+ limit: EXPORT_LIMIT,
+ offset: 0,
+ }),
+ });
+ if (!res.ok) throw new Error();
+ const json: { data: PropertyWithRelations[] } = await res.json();
+ exportToCsv(json.data);
+ } catch {
+ // Don't fail silently — a data-trust product must say when an export dies.
+ setExportError("Export failed — please try again.");
+ } finally {
+ setIsExporting(false);
+ }
+ }, [isExporting, portfolioId, allFilterGroups]);
return (
@@ -532,6 +611,31 @@ export default function PropertyTable({
properties
)}
+ {(selectedIds.length > 0 || selectAllMatching) && (
+
+ {selectAllMatching
+ ? `All ${matchingCount.toLocaleString()} selected`
+ : `${selectedIds.length.toLocaleString()} selected`}
+
+ Clear
+
+
+ )}
+ {exportError && (
+
+ {exportError}
+ setExportError(null)}
+ aria-label="Dismiss"
+ className="text-red-400 hover:text-red-700"
+ >
+
+
+
+ )}
{hasActiveFilters && (
{OPTIONAL_COLUMN_LABELS[colId]}
@@ -619,19 +723,32 @@ export default function PropertyTable({
) : (
exportToCsv(tableData)}
- disabled={isLoading || tableData.length === 0}
+ onClick={handleExport}
+ disabled={isLoading || isExporting || filteredTotal === 0}
className="flex items-center gap-1.5 h-8 px-3 rounded-lg border border-slate-200 bg-slate-100 text-xs font-semibold text-primary hover:bg-slate-200 transition disabled:opacity-50 disabled:cursor-not-allowed"
>
- Export
+ {isExporting ? "Exporting…" : "Export"}
)}
- {/* Add properties */}
+ {/* Tags — bulk assign / remove / upload (ADR-0013) */}
+ setTagUploadOpen(true)}
+ onAssign={() => {
+ clearSelection();
+ setTagMode("assign");
+ }}
+ onRemove={() => {
+ clearSelection();
+ setTagMode("remove");
+ }}
+ />
+
+ {/* Add properties — primary CTA only while the portfolio is empty */}
-
+ 0 ? SECONDARY_CTA : PRIMARY_CTA}>
Add properties
@@ -655,33 +772,42 @@ export default function PropertyTable({
setBulkImportOpen(true)}
>
-
+
-
+
Bulk excel import
Upload a spreadsheet of addresses
-
- Soon
-
- {/* Run modelling */}
-
router.push(`/portfolio/${portfolioId}/modelling/run`)}
- className="flex items-center gap-1.5 h-8 px-3 rounded-lg bg-primary text-white text-xs font-semibold hover:opacity-90 transition"
- >
-
- Run modelling
-
+
setBulkImportOpen(false)}
+ portfolioId={portfolioId}
+ />
+
+ {/* Run modelling — primary CTA once there are properties to model.
+ Hidden while the not-modelled banner is up, since the banner already
+ carries this action (no duplicate navy CTA). */}
+ {!showModelNudge && (
+
+ router.push(`/portfolio/${portfolioId}/modelling/run`)
+ }
+ className={totalCount > 0 ? PRIMARY_CTA : SECONDARY_CTA}
+ >
+
+ Run modelling
+
+ )}
@@ -736,6 +862,74 @@ export default function PropertyTable({
/>
+ {/* Contextual bulk assign/remove strip — shown only while in that mode
+ (launched from the Tags menu); its target follows the live selection. */}
+ {tagMode && (
+
setSelectAllMatching(true)}
+ onClearSelection={clearSelection}
+ onClose={() => {
+ setTagMode(null);
+ clearSelection();
+ }}
+ />
+ )}
+
+
+
+ {/* Not-modelled nudge — turns a wall of empty cells into a next step.
+ Mixed-safe: shown whenever any loaded property lacks a plan, so a
+ part-modelled portfolio still gets the prompt for the rest. */}
+ {showModelNudge && (
+
+
+
+
+
+ {unmodelledInView === totalCount
+ ? "None of these properties have been modelled yet"
+ : `${unmodelledInView.toLocaleString()} ${unmodelledInView === 1 ? "property hasn't" : "properties haven't"} been modelled yet`}
+
+
+ Run modelling to generate Expected EPC ratings and retrofit
+ costs for them.
+
+
+
+
+
+ router.push(`/portfolio/${portfolioId}/modelling/run`)
+ }
+ className="inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-semibold text-white transition hover:opacity-90"
+ >
+
+ Run modelling
+
+
setModelNudgeDismissed(true)}
+ aria-label="Dismiss"
+ className="rounded-md p-1.5 text-slate-400 transition hover:text-brandblue"
+ >
+
+
+
+
+ )}
+
{/* Display-limit notice */}
{isAtDisplayLimit && hasMore && (
@@ -770,6 +964,7 @@ export default function PropertyTable({
Curate Selection
@@ -803,8 +998,7 @@ export default function PropertyTable({
) : (
setDeletePropertyId(id)}
+ columns={tagMode ? columns : columnsWithoutSelect}
columnVisibility={columnVisibility}
onColumnVisibilityChange={
setColumnVisibility as (
@@ -815,61 +1009,12 @@ export default function PropertyTable({
onPaginationChange={
setPagination as (updater: Updater) => void
}
+ rowSelection={rowSelection}
+ onRowSelectionChange={handleRowSelectionChange}
/>
)}
-
- {/* Delete preview modal */}
- {
- if (!open) {
- setDeletePropertyId(null);
- setDeletePreview(null);
- }
- }}
- >
-
-
- Delete property?
-
- {previewLoading
- ? "Calculating what will be deleted…"
- : "This action is permanent. Review the impact below."}
-
-
-
- {previewError && (
- {previewError}
- )}
-
- {deletePreview && !previewLoading && (
-
- {deletePreview.map((row) => (
-
-
- {row.table.replace(/_/g, " ")}
-
- {row.count}
-
- ))}
-
- )}
-
-
- {
- setDeletePropertyId(null);
- setDeletePreview(null);
- }}
- >
- Cancel
-
-
-
-
);
}
diff --git a/src/app/portfolio/[slug]/components/TagActionBar.tsx b/src/app/portfolio/[slug]/components/TagActionBar.tsx
new file mode 100644
index 00000000..e663417c
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/TagActionBar.tsx
@@ -0,0 +1,213 @@
+"use client";
+
+import { useState } from "react";
+import { useMutation } from "@tanstack/react-query";
+import { CheckIcon, ChevronDownIcon, XMarkIcon } from "@heroicons/react/24/outline";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/app/shadcn_components/ui/dropdown-menu";
+import { FilterGroups } from "@/app/utils/propertyFilters";
+import { tagDotColour } from "@/lib/tags/colour";
+import { Tag, useInvalidateTagSurfaces, usePortfolioTags } from "./useTags";
+
+export type TagMode = "assign" | "remove";
+
+/**
+ * The contextual strip shown while assigning or removing a tag in bulk
+ * (ADR-0013). The target is explicit: the ticked rows, or — after ticking every
+ * loaded row — "all N matching", which the user escalates to deliberately and
+ * which resolves the whole matching set server-side (not just the loaded page).
+ * With nothing selected there is no target, so a tag can't be applied by
+ * accident. Picking a tag adds/removes memberships and reports the count.
+ */
+export function TagActionBar({
+ portfolioId,
+ mode,
+ selectedIds,
+ selectAllMatching,
+ hasActiveFilters,
+ filterGroups,
+ matchingCount,
+ allLoadedSelected,
+ moreMatchThanLoaded,
+ onSelectAllMatching,
+ onClearSelection,
+ onClose,
+}: {
+ portfolioId: string;
+ mode: TagMode;
+ selectedIds: string[];
+ selectAllMatching: boolean;
+ hasActiveFilters: boolean;
+ filterGroups: FilterGroups;
+ matchingCount: number;
+ allLoadedSelected: boolean;
+ moreMatchThanLoaded: boolean;
+ onSelectAllMatching: () => void;
+ onClearSelection: () => void;
+ onClose: () => void;
+}) {
+ const { data: tags = [] } = usePortfolioTags(portfolioId);
+ const invalidate = useInvalidateTagSurfaces(portfolioId);
+ const [result, setResult] = useState(null);
+
+ const action = mode === "assign" ? "add" : "remove";
+ const verb = mode === "assign" ? "Assign" : "Remove";
+ const prep = mode === "assign" ? "to" : "from";
+
+ // The current target — explicit selection only (no implicit "all"). Selecting
+ // all matching is a deliberate escalation that switches to the filter path.
+ type Target = {
+ body:
+ | { mode: "properties"; propertyIds: string[] }
+ | { mode: "filter"; filterGroups: FilterGroups };
+ label: string;
+ };
+ const target: Target | null = selectAllMatching
+ ? {
+ body: {
+ mode: "filter",
+ filterGroups: hasActiveFilters ? filterGroups : [],
+ },
+ label: hasActiveFilters
+ ? `all ${matchingCount.toLocaleString()} matching your filter`
+ : `all ${matchingCount.toLocaleString()} properties`,
+ }
+ : selectedIds.length > 0
+ ? {
+ body: { mode: "properties", propertyIds: selectedIds },
+ label: `${selectedIds.length.toLocaleString()} selected propert${selectedIds.length === 1 ? "y" : "ies"}`,
+ }
+ : null;
+
+ const apply = useMutation<{ changed: number }, Error, Tag>({
+ mutationFn: async (tag) => {
+ if (!target) throw new Error("Select some properties first");
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/tags/${tag.id}/assignments`,
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ ...target.body, action }),
+ },
+ );
+ const body = await res.json();
+ if (!res.ok) throw new Error(body.error ?? "Couldn't update tags");
+ return body;
+ },
+ onSuccess: (data, tag) => {
+ setResult(
+ `${mode === "assign" ? "Added" : "Removed"} “${tag.name}” ${prep} ${data.changed.toLocaleString()} propert${data.changed === 1 ? "y" : "ies"}.`,
+ );
+ invalidate();
+ },
+ onError: (e) => setResult(e.message),
+ });
+
+ const showEscalate =
+ !selectAllMatching && allLoadedSelected && moreMatchThanLoaded;
+
+ return (
+
+
{verb} a tag
+
+
+ {target ? (
+ <>
+ {prep}{" "}
+ {target.label}
+ >
+ ) : (
+
+ Tick properties to {mode === "assign" ? "tag" : "untag"} them
+
+ )}
+
+
+ {/* Deliberate escalation to the whole matching set (Gmail pattern) —
+ a clear secondary button (white fill + brand border) so it stands out
+ on the tinted bar without competing with the navy "Choose a tag". */}
+ {showEscalate && (
+
+
+ Select all {matchingCount.toLocaleString()}
+ {hasActiveFilters ? " matching" : ""}
+
+ )}
+ {selectAllMatching && (
+
+ Clear selection
+
+ )}
+
+
+
+
+ {apply.isLoading ? "Applying…" : "Choose a tag"}
+
+
+
+
+
+ {verb} which tag?
+
+
+ {tags.length === 0 ? (
+
+ ) : (
+ tags.map((t) => (
+ apply.mutate(t)}
+ >
+
+ {t.name}
+
+ ))
+ )}
+
+
+
+ {result && (
+
+ {result}
+
+ )}
+
+
+
+ Done
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/TagChip.tsx b/src/app/portfolio/[slug]/components/TagChip.tsx
new file mode 100644
index 00000000..f2bb8f9c
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/TagChip.tsx
@@ -0,0 +1,59 @@
+"use client";
+
+import { X } from "lucide-react";
+import { tagChipTokens } from "@/lib/tags/colour";
+
+/**
+ * A Tag chip in the app's one calm, AA-safe chip vocabulary (ADR-0013,
+ * PRODUCT.md): a soft tint of the Tag's freeform hex, a colour dot, and dark
+ * hue-preserving ink that stays legible for any colour. Shared across the
+ * property table, tags filter, bulk bar, upload, settings, and run UI so every
+ * surface reads as one system.
+ */
+export function TagChip({
+ name,
+ colour,
+ size = "sm",
+ onRemove,
+ title,
+}: {
+ name: string;
+ colour: string;
+ size?: "xs" | "sm";
+ onRemove?: () => void;
+ title?: string;
+}) {
+ const tokens = tagChipTokens(colour);
+ const sizing =
+ size === "xs"
+ ? "gap-1 px-1.5 py-0.5 text-[10px]"
+ : "gap-1.5 px-2 py-0.5 text-[11px]";
+ const dot = size === "xs" ? "h-1.5 w-1.5" : "h-2 w-2";
+ return (
+
+
+ {name}
+ {onRemove && (
+ {
+ e.stopPropagation();
+ onRemove();
+ }}
+ className="-mr-0.5 shrink-0 rounded-full opacity-70 transition hover:opacity-100"
+ aria-label={`Remove ${name}`}
+ >
+
+
+ )}
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/TagsCell.tsx b/src/app/portfolio/[slug]/components/TagsCell.tsx
new file mode 100644
index 00000000..004a2df1
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/TagsCell.tsx
@@ -0,0 +1,208 @@
+"use client";
+
+import { useState } from "react";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { Check, Plus, Tag as TagIcon } from "lucide-react";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/app/shadcn_components/ui/popover";
+import { PropertyWithRelations, PropertyTag } from "@/app/db/schema/property";
+import { tagDotColour } from "@/lib/tags/colour";
+import { TagChip } from "./TagChip";
+import {
+ Tag,
+ usePortfolioTags,
+ portfolioTagsKey,
+} from "./useTags";
+import type { PropertiesResponse } from "./useProperties";
+
+/** How many chips to show inline before collapsing the rest into "+N". */
+const MAX_VISIBLE_CHIPS = 2;
+
+type AssignVars = { tag: Tag; action: "add" | "remove" };
+
+/**
+ * The property table's Tags cell (ADR-0013): shows the property's Tags as chips
+ * with a "+N" overflow, and an assign popover that toggles membership against
+ * POST …/assignments {mode:"properties"}. Writes are optimistic across every
+ * cached property-table query for this portfolio, reconciled on settle.
+ */
+export function TagsCell({ property }: { property: PropertyWithRelations }) {
+ const portfolioId = String(property.portfolioId);
+ const propertyId = String(property.id);
+ const tags = property.tags ?? [];
+
+ const [open, setOpen] = useState(false);
+ const queryClient = useQueryClient();
+ const { data: allTags = [], isLoading, isError } = usePortfolioTags(portfolioId);
+
+ const assignedIds = new Set(tags.map((t) => t.id));
+
+ const assign = useMutation({
+ mutationFn: async ({ tag, action }) => {
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/tags/${tag.id}/assignments`,
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ mode: "properties",
+ action,
+ propertyIds: [propertyId],
+ }),
+ },
+ );
+ if (!res.ok) {
+ const body = await res.json().catch(() => ({}));
+ throw new Error(body.error ?? "Couldn't update tags");
+ }
+ return res.json();
+ },
+ // Optimistically add/remove the chip on every cached property-table page.
+ onMutate: async ({ tag, action }) => {
+ await queryClient.cancelQueries({ queryKey: ["properties", portfolioId] });
+ const snapshot = queryClient.getQueriesData({
+ queryKey: ["properties", portfolioId],
+ });
+ const chip: PropertyTag = { id: tag.id, name: tag.name, colour: tag.colour };
+ queryClient.setQueriesData(
+ { queryKey: ["properties", portfolioId] },
+ (prev) =>
+ prev
+ ? {
+ ...prev,
+ data: prev.data.map((row) =>
+ String(row.id) === propertyId
+ ? { ...row, tags: nextTags(row.tags ?? [], chip, action) }
+ : row,
+ ),
+ }
+ : prev,
+ );
+ return { snapshot };
+ },
+ onError: (_e, _vars, context) => {
+ context?.snapshot.forEach(([key, data]) =>
+ queryClient.setQueryData(key, data),
+ );
+ },
+ onSettled: () => {
+ queryClient.invalidateQueries({ queryKey: ["properties", portfolioId] });
+ queryClient.invalidateQueries({ queryKey: portfolioTagsKey(portfolioId) });
+ },
+ });
+
+ const visible = tags.slice(0, MAX_VISIBLE_CHIPS);
+ const overflow = tags.length - visible.length;
+
+ return (
+
+
+
+ {tags.length === 0 ? (
+
+
+ Tag
+
+ ) : (
+ <>
+ {visible.map((t) => (
+
+ ))}
+ {overflow > 0 && (
+
+ +{overflow}
+
+ )}
+ >
+ )}
+
+
+
+
+
Assign tags
+
+ {property.address ?? "This property"}
+
+
+
+ {isLoading ? (
+
Loading tags…
+ ) : isError ? (
+
Couldn't load tags.
+ ) : allTags.length === 0 ? (
+
+ ) : (
+ allTags.map((t) => {
+ const on = assignedIds.has(t.id);
+ return (
+
+ assign.mutate({ tag: t, action: on ? "remove" : "add" })
+ }
+ className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition hover:bg-slate-50"
+ >
+
+
+ {t.name}
+
+
+ {on && }
+
+
+ );
+ })
+ )}
+
+
+
+
+ );
+}
+
+/** Add or remove a chip from a property's tag list, keeping it name-ordered. */
+function nextTags(
+ current: PropertyTag[],
+ chip: PropertyTag,
+ action: "add" | "remove",
+): PropertyTag[] {
+ if (action === "remove") return current.filter((t) => t.id !== chip.id);
+ if (current.some((t) => t.id === chip.id)) return current;
+ return [...current, chip].sort((a, b) => a.name.localeCompare(b.name));
+}
diff --git a/src/app/portfolio/[slug]/components/TagsMenu.tsx b/src/app/portfolio/[slug]/components/TagsMenu.tsx
new file mode 100644
index 00000000..ad1f02a5
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/TagsMenu.tsx
@@ -0,0 +1,88 @@
+"use client";
+
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/app/shadcn_components/ui/dropdown-menu";
+import {
+ ChevronDownIcon,
+ DocumentArrowUpIcon,
+ PlusIcon,
+ MinusIcon,
+ TagIcon,
+} from "@heroicons/react/24/outline";
+
+/**
+ * The single Tags entry point in the property-table toolbar (ADR-0013): a
+ * dropdown offering the three bulk-tag paths. Upload opens the file modal;
+ * Assign / Remove enter a contextual mode (TagActionBar) that operates on the
+ * row selection or the active filter. Consolidates what was an isolated button.
+ */
+export function TagsMenu({
+ onUpload,
+ onAssign,
+ onRemove,
+}: {
+ onUpload: () => void;
+ onAssign: () => void;
+ onRemove: () => void;
+}) {
+ return (
+
+
+
+
+ Tags
+
+
+
+
+ }
+ title="Upload tags from file"
+ desc="Match a spreadsheet of IDs to a tag"
+ onSelect={onUpload}
+ />
+ }
+ title="Assign a tag"
+ desc="Apply a tag to selected rows or your filtered results"
+ onSelect={onAssign}
+ />
+ }
+ title="Remove a tag"
+ desc="Take a tag off selected rows or your filtered results"
+ onSelect={onRemove}
+ />
+
+
+ );
+}
+
+function Item({
+ icon,
+ title,
+ desc,
+ onSelect,
+}: {
+ icon: React.ReactNode;
+ title: string;
+ desc: string;
+ onSelect: () => void;
+}) {
+ return (
+
+ {icon}
+
+ {title}
+ {desc}
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/UnmatchedProperties.tsx b/src/app/portfolio/[slug]/components/UnmatchedProperties.tsx
new file mode 100644
index 00000000..024d4225
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/UnmatchedProperties.tsx
@@ -0,0 +1,92 @@
+import {
+ ExclamationTriangleIcon,
+ CheckCircleIcon,
+} from "@heroicons/react/24/outline";
+import type { UnmatchedProperty } from "@/lib/properties/unmatched";
+import MatchAddress from "./MatchAddress";
+
+// The "Needs attention" tab: properties with no UPRN, separated out of the main
+// table until they're matched. Each row lets the user correct the address /
+// postcode (UPRN matching is a later step).
+export default function UnmatchedProperties({
+ properties,
+ portfolioId,
+}: {
+ properties: UnmatchedProperty[];
+ portfolioId: string;
+}) {
+ const count = properties.length;
+
+ if (count === 0) {
+ return (
+
+
+
+ All properties are matched
+
+
+ Every property has a UPRN — nothing needs attention.
+
+
+ );
+ }
+
+ return (
+
+
+
+
+
+
+ Properties without a UPRN
+
+
+ {count}
+
+
+
+ {count === 1 ? "This property" : "These properties"} couldn't be
+ matched by AraAddressMatcher automatically. Double check the{" "}
+ {count === 1 ? "address" : "addresses"} and Ara will try again with
+ AraAddressMatcherPlus.
+
+
+
+
+
+
+
Address
+
Postcode
+
Action
+
+
+
+
+
+ );
+}
diff --git a/src/app/portfolio/[slug]/components/dataTable.tsx b/src/app/portfolio/[slug]/components/dataTable.tsx
index 18acbb79..a2a9b456 100644
--- a/src/app/portfolio/[slug]/components/dataTable.tsx
+++ b/src/app/portfolio/[slug]/components/dataTable.tsx
@@ -6,6 +6,7 @@ import {
SortingState,
PaginationState,
VisibilityState,
+ RowSelectionState,
Updater,
flexRender,
getCoreRowModel,
@@ -50,6 +51,9 @@ interface DataTableProps {
// Controlled pagination — when omitted the table manages its own pagination state
pagination?: PaginationState;
onPaginationChange?: (updater: Updater) => void;
+ // Controlled row selection — when omitted, selection is disabled/uncontrolled
+ rowSelection?: RowSelectionState;
+ onRowSelectionChange?: (updater: Updater) => void;
}
export default function DataTable>({
@@ -60,6 +64,8 @@ export default function DataTable>({
onColumnVisibilityChange,
pagination: controlledPagination,
onPaginationChange: controlledOnPaginationChange,
+ rowSelection,
+ onRowSelectionChange,
}: DataTableProps) {
const [sorting, setSorting] = useState([]);
const [columnFilters, setColumnFilters] = useState([]);
@@ -70,22 +76,35 @@ export default function DataTable>({
const pagination = isControlled ? controlledPagination : internalPagination;
const onPaginationChange = isControlled ? controlledOnPaginationChange! : setInternalPagination;
+ const selectionEnabled = rowSelection !== undefined;
+
const table = useReactTable({
data,
columns,
+ // Only override row identity when selection is in use: the property table
+ // needs id-keyed rows so a selection survives pagination + lazy-loaded pages.
+ // Other consumers (e.g. the plan table) keep TanStack's default index-based
+ // identity untouched. The idless fallback guards a selection-enabled table
+ // whose rows happen to lack an id.
+ getRowId: selectionEnabled
+ ? (row, index) => (row.id != null ? String(row.id) : String(index))
+ : undefined,
+
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getPaginationRowModel: getPaginationRowModel(),
autoResetPageIndex: false,
+ enableRowSelection: selectionEnabled,
onSortingChange: setSorting,
onColumnFiltersChange: setColumnFilters,
onGlobalFilterChange: setGlobalFilter,
onPaginationChange,
onColumnVisibilityChange,
+ onRowSelectionChange,
globalFilterFn: fuzzyFilter,
@@ -95,6 +114,7 @@ export default function DataTable>({
globalFilter,
pagination,
columnVisibility,
+ rowSelection: rowSelection ?? {},
},
meta: {
diff --git a/src/app/portfolio/[slug]/components/propertyTableColumns.tsx b/src/app/portfolio/[slug]/components/propertyTableColumns.tsx
index 9d2955d5..9a0111de 100644
--- a/src/app/portfolio/[slug]/components/propertyTableColumns.tsx
+++ b/src/app/portfolio/[slug]/components/propertyTableColumns.tsx
@@ -17,12 +17,10 @@ import { cn } from "@/lib/utils";
import { PropertyWithRelations } from "@/app/db/schema/property";
import { expectedEpcRating } from "./expectedEpc";
import { X } from "lucide-react";
-import {
- EnumOption,
- TENURE_OPTIONS,
- MAINFUEL_OPTIONS,
-} from "@/app/utils/propertyFilters";
+import { EnumOption, MAINFUEL_OPTIONS } from "@/app/utils/propertyFilters";
import { CurrentEpcTooltip } from "./CurrentEpcTooltip";
+import { TagsCell } from "./TagsCell";
+import { Checkbox } from "@/app/shadcn_components/ui/checkbox";
/* -----------------------------------------------------------------------
Helpers
@@ -36,13 +34,6 @@ function resolveEnumLabel(
return opt?.label ?? dbValue;
}
-function tenureBadgeClass(label: string): string {
- if (label.toLowerCase().includes("owner")) return "bg-blue-50 text-blue-700";
- if (label.toLowerCase().includes("private")) return "bg-violet-50 text-violet-700";
- if (label.toLowerCase().includes("social")) return "bg-emerald-50 text-emerald-700";
- return "bg-slate-100 text-slate-500";
-}
-
function Pill({
children,
className = "bg-slate-100 text-slate-600",
@@ -62,8 +53,29 @@ function Pill({
/* -----------------------------------------------------------------------
EPC letter bubble
------------------------------------------------------------------------ */
+/**
+ * The one treatment for an absent value across the table (ADR-0013 impeccable
+ * pass): a single quiet, AA-legible em-dash with an accessible label — replacing
+ * the four different empty renderings (blank div, slate-300 "—", italic
+ * "No cost", "Unknown") the critique flagged.
+ */
+const EmptyCell = ({ label = "No data" }: { label?: string }) => (
+
+ —
+
+);
+
const EpcLetterBubble = ({ letter }: { letter: string }) => {
- if (!letter) return
;
+ if (!letter)
+ return (
+
+ –
+
+ );
return (
({
Column metadata
------------------------------------------------------------------------ */
export const OPTIONAL_COLUMN_IDS = [
+ "tags",
"propertyType",
"builtForm",
- "tenure",
"yearBuilt",
"totalFloorArea",
"co2Emissions",
"mainfuel",
+ "wallType",
+ "roofType",
+ "heatingSystem",
] as const;
export type OptionalColumnId = (typeof OPTIONAL_COLUMN_IDS)[number];
const OPTIONAL_COLUMN_LABELS: Record
= {
+ tags: "Tags",
propertyType: "Property Type",
builtForm: "Built Form",
- tenure: "Tenure",
- yearBuilt: "Year Built",
+ yearBuilt: "Construction Age",
totalFloorArea: "Floor Area (m²)",
co2Emissions: "CO₂ Emissions",
mainfuel: "Main Fuel",
+ wallType: "Wall Type",
+ roofType: "Roof Type",
+ heatingSystem: "Heating System",
};
export { OPTIONAL_COLUMN_LABELS };
@@ -193,6 +211,34 @@ export { OPTIONAL_COLUMN_LABELS };
Core columns
------------------------------------------------------------------------ */
const coreColumns: ColumnDef[] = [
+ {
+ id: "select",
+ enableSorting: false,
+ enableHiding: false,
+ // Selects ALL loaded rows (not just the paginated page), so on a small page
+ // size it still covers everything in view. When more properties match than
+ // are loaded, the TagActionBar offers "Select all N matching" on top of this.
+ header: ({ table }) => (
+ table.toggleAllRowsSelected(!!v)}
+ />
+ ),
+ cell: ({ row }) => (
+ row.toggleSelected(!!v)}
+ />
+ ),
+ },
{
accessorKey: "address",
enableGlobalFilter: true,
@@ -231,10 +277,18 @@ const coreColumns: ColumnDef[] = [
header: () => Property Ref
,
cell: ({ row }) => (
- {row.original.landlordPropertyId ?? "—"}
+ {row.original.landlordPropertyId ?? }
),
},
+ {
+ id: "tags",
+ // Toggle-able (in OPTIONAL_COLUMN_IDS) but default-visible — see PropertyTable.
+ // Not sortable/filterable here; the tags filter lives in PropertyFilters.
+ enableSorting: false,
+ header: () => Tags
,
+ cell: ({ row }) => ,
+ },
{
accessorKey: "currentEpc",
header: () => (
@@ -303,7 +357,11 @@ const coreColumns: ColumnDef[] = [
const expired = row.original.epcIsExpired;
if (!dateStr) {
- return —
;
+ return (
+
+
+
+ );
}
const lodgementDate = new Date(dateStr);
@@ -345,13 +403,13 @@ const coreColumns: ColumnDef[] = [
}
return (
-
+
{cost ? (
£{formatNumber(cost)}
) : (
- No cost
+
)}
);
@@ -409,7 +467,7 @@ const optionalColumns: ColumnDef
[] = [
header: () => Property Type
,
cell: ({ row }) => {
const val = row.original.propertyType;
- return val ? {val} : — ;
+ return val ? {val} : ;
},
},
{
@@ -418,25 +476,17 @@ const optionalColumns: ColumnDef[] = [
header: () => Built Form
,
cell: ({ row }) => {
const val = row.original.builtForm;
- return val ? {val} : — ;
- },
- },
- {
- id: "tenure",
- accessorKey: "tenure",
- header: () => Tenure
,
- cell: ({ row }) => {
- const label = resolveEnumLabel(TENURE_OPTIONS, row.original.tenure);
- if (!label) return — ;
- return {label} ;
+ return val ? {val} : ;
},
},
{
id: "yearBuilt",
accessorKey: "yearBuilt",
- header: () => Year Built
,
+ header: () => Construction Age
,
cell: ({ row }) => (
- {row.original.yearBuilt ?? "—"}
+
+ {row.original.yearBuilt ?? }
+
),
},
{
@@ -447,7 +497,7 @@ const optionalColumns: ColumnDef[] = [
const val = row.original.totalFloorArea;
return (
- {val != null ? `${val.toFixed(1)} m²` : "—"}
+ {val != null ? `${val.toFixed(1)} m²` : }
);
},
@@ -460,7 +510,7 @@ const optionalColumns: ColumnDef[] = [
const val = row.original.co2Emissions;
return (
- {val != null ? `${val.toFixed(1)} kg/m²/yr` : "—"}
+ {val != null ? `${val.toFixed(1)} kg/m²/yr` : }
);
},
@@ -471,12 +521,52 @@ const optionalColumns: ColumnDef[] = [
header: () => Main Fuel
,
cell: ({ row }) => {
const label = resolveEnumLabel(MAINFUEL_OPTIONS, row.original.mainfuel);
- return label ? {label} : — ;
+ return label ? {label} : ;
},
},
+ {
+ id: "wallType",
+ accessorKey: "wallType",
+ header: () => Wall Type
,
+ cell: ({ row }) => ,
+ },
+ {
+ id: "roofType",
+ accessorKey: "roofType",
+ header: () => Roof Type
,
+ cell: ({ row }) => ,
+ },
+ {
+ id: "heatingSystem",
+ accessorKey: "heatingSystem",
+ header: () => Heating System
,
+ cell: ({ row }) => ,
+ },
];
+/** Long free-text descriptor (wall/roof/heating): truncate with a full-value tooltip; muted when Unknown. */
+function DescriptorCell({ value }: { value: string | null }) {
+ const val = value ?? "Unknown";
+ return (
+
+ {val}
+
+ );
+}
+
export const columns: ColumnDef[] = [
...coreColumns,
...optionalColumns,
];
+
+// The same columns without the leading selection checkbox — row-select is only
+// shown while bulk-tagging (ADR-0013 impeccable pass), so the default table has
+// no persistent checkbox column. Precomputed (stable identity, no useMemo).
+export const columnsWithoutSelect: ColumnDef[] =
+ columns.filter((c) => c.id !== "select");
diff --git a/src/app/portfolio/[slug]/components/useTags.ts b/src/app/portfolio/[slug]/components/useTags.ts
new file mode 100644
index 00000000..582f48c9
--- /dev/null
+++ b/src/app/portfolio/[slug]/components/useTags.ts
@@ -0,0 +1,45 @@
+"use client";
+
+import { useQuery, useQueryClient } from "@tanstack/react-query";
+
+/** A portfolio Tag as returned by GET /api/portfolio/[id]/tags (ADR-0013). */
+export interface Tag {
+ id: string;
+ name: string;
+ colour: string;
+ propertyCount: number;
+}
+
+/** Shared query key so every tag surface (settings, table, filter) stays in sync. */
+export function portfolioTagsKey(portfolioId: string) {
+ return ["portfolio-tags", portfolioId] as const;
+}
+
+export async function fetchTags(portfolioId: string): Promise {
+ const res = await fetch(`/api/portfolio/${portfolioId}/tags`);
+ if (!res.ok) throw new Error("Failed to load tags");
+ return res.json();
+}
+
+/**
+ * The portfolio's Tags, deduped across every component that reads them (chips,
+ * assign popover, filter, run UI) via a shared query key. TanStack v4 — reads
+ * with `isLoading`.
+ */
+export function usePortfolioTags(portfolioId: string) {
+ return useQuery({
+ queryKey: portfolioTagsKey(portfolioId),
+ queryFn: () => fetchTags(portfolioId),
+ refetchOnWindowFocus: false,
+ staleTime: 60_000,
+ });
+}
+
+/** Invalidate the tags list + the property table so freshly-assigned chips show. */
+export function useInvalidateTagSurfaces(portfolioId: string) {
+ const queryClient = useQueryClient();
+ return () => {
+ queryClient.invalidateQueries({ queryKey: portfolioTagsKey(portfolioId) });
+ queryClient.invalidateQueries({ queryKey: ["properties", portfolioId] });
+ };
+}
diff --git a/src/app/portfolio/[slug]/modelling/run/RunModellingClient.tsx b/src/app/portfolio/[slug]/modelling/run/RunModellingClient.tsx
index 3d4808d4..fa074bc8 100644
--- a/src/app/portfolio/[slug]/modelling/run/RunModellingClient.tsx
+++ b/src/app/portfolio/[slug]/modelling/run/RunModellingClient.tsx
@@ -15,6 +15,8 @@ import {
MAX_FILTER_POSTCODES,
selectionSummary,
} from "@/lib/modellingRuns/model";
+import { usePortfolioTags } from "@/app/portfolio/[slug]/components/useTags";
+import { tagDotColour } from "@/lib/tags/colour";
export interface ScenarioOption {
id: string;
@@ -77,11 +79,13 @@ function FilterColumn({
options,
selected,
onToggle,
+ emptyHint,
}: {
title: string;
- options: { value: string; count?: number }[];
+ options: { value: string; label?: string; count?: number; colour?: string }[];
selected: Set;
onToggle: (value: string) => void;
+ emptyHint?: React.ReactNode;
}) {
return (
@@ -94,28 +98,38 @@ function FilterColumn({
);
@@ -135,6 +149,7 @@ export default function RunModellingClient({
const [selPcs, setSelPcs] = useState>(new Set());
const [selTypes, setSelTypes] = useState>(new Set());
const [selForms, setSelForms] = useState>(new Set());
+ const [selTags, setSelTags] = useState>(new Set());
const [confirmOpen, setConfirmOpen] = useState(false);
const [done, setDone] = useState<{ properties: number; scenarios: number } | null>(null);
@@ -142,9 +157,12 @@ export default function RunModellingClient({
...(selPcs.size ? { postcodes: [...selPcs].sort() } : {}),
...(selTypes.size ? { propertyTypes: [...selTypes] } : {}),
...(selForms.size ? { builtForms: [...selForms] } : {}),
+ ...(selTags.size ? { tagIds: [...selTags].map(Number) } : {}),
};
const scenarioIds = [...selScenarios].sort();
+ const { data: tags = [] } = usePortfolioTags(portfolioId);
+
const postcodesQuery = useQuery<{ postcode: string; count: number }[], Error>({
queryKey: ["portfolio-postcodes", portfolioId],
staleTime: 5 * 60 * 1000,
@@ -219,15 +237,21 @@ export default function RunModellingClient({
const remodel = (preview.data?.perScenario ?? []).filter((p) => p.alreadyModelled > 0);
const scenarioById = new Map(scenarios.map((s) => [s.id, s]));
const startRun = () => {
+ if (tagsBlockRun) return;
if (matched != null && isLargeRun(matched)) setConfirmOpen(true);
else run.mutate();
};
- const filterCount = selPcs.size + selTypes.size + selForms.size;
+ const filterCount = selPcs.size + selTypes.size + selForms.size + selTags.size;
const clearFilters = () => {
setSelPcs(new Set());
setSelTypes(new Set());
setSelForms(new Set());
+ setSelTags(new Set());
};
+ // The distributor can't resolve tag_ids yet (backend ask pending, ADR-0013):
+ // preview counts tags in-app, but an actual run would model the unscoped set.
+ // Guard the run until the backend lands — remove this once it does.
+ const tagsBlockRun = selTags.size > 0;
return (
@@ -376,7 +400,7 @@ export default function RunModellingClient({
takes priority over its EPC; “Unknown” picks out homes where we have
neither.
-
+
{postcodesQuery.isError ? (
@@ -422,10 +446,26 @@ export default function RunModellingClient({
selected={selForms}
onToggle={(v) => toggle(selForms, setSelForms, v)}
/>
+ ({
+ value: t.id,
+ label: t.name,
+ colour: t.colour,
+ count: t.propertyCount,
+ }))}
+ selected={selTags}
+ onToggle={(v) => toggle(selTags, setSelTags, v)}
+ emptyHint={
+ <>
+ No tags yet — create them from the property table to run a
+ scenario over a hand-picked group.
+ >
+ }
+ />
- Filters are limited to {MAX_FILTER_POSTCODES} postcodes per run. Tags are coming —
- you'll be able to save a selection and reuse it.
+ Filters are limited to {MAX_FILTER_POSTCODES} postcodes per run.
@@ -560,17 +600,34 @@ export default function RunModellingClient({
{run.isLoading
? "Starting…"
- : matched
- ? `Run modelling — ${planTotal!.toLocaleString()} plan${planTotal === 1 ? "" : "s"}`
- : "No properties match"}
+ : tagsBlockRun
+ ? "Tag runs coming soon"
+ : matched
+ ? `Run modelling — ${planTotal!.toLocaleString()} plan${planTotal === 1 ? "" : "s"}`
+ : "No properties match"}
+ {tagsBlockRun && (
+
+
+ You can preview a tag selection now, but running scenarios over
+ tags needs a modelling-engine update that's on the way. The
+ count above is exact — the run button unlocks once it lands.
+
+
+ )}
{(remodel.length > 0 || run.isError) && (
{remodel.map((p) => (
diff --git a/src/app/portfolio/[slug]/properties/add/AddPropertiesClient.tsx b/src/app/portfolio/[slug]/properties/add/AddPropertiesClient.tsx
index 81707862..4276e4a0 100644
--- a/src/app/portfolio/[slug]/properties/add/AddPropertiesClient.tsx
+++ b/src/app/portfolio/[slug]/properties/add/AddPropertiesClient.tsx
@@ -44,6 +44,7 @@ export default function AddPropertiesClient({
const [input, setInput] = useState("");
const [inputError, setInputError] = useState
(null);
const [search, setSearch] = useState<{ pc: string; refresh: number } | null>(null);
+ const [filter, setFilter] = useState("");
const [basket, setBasket] = useState({});
const [done, setDone] = useState<{ added: number; skipped: number } | null>(null);
@@ -110,6 +111,7 @@ export default function AddPropertiesClient({
}
setInputError(null);
setDone(null);
+ setFilter("");
setSearch({ pc, refresh: 0 });
};
@@ -130,6 +132,12 @@ export default function AddPropertiesClient({
const addable = data
? data.candidates.filter((c) => c.selectable && !c.alreadyInPortfolio)
: [];
+ const needle = filter.trim().toLowerCase();
+ const visible = data
+ ? needle
+ ? data.candidates.filter((c) => c.address.toLowerCase().includes(needle))
+ : data.candidates
+ : [];
const totalSelected = countSelected(basket);
const postcodes = Object.keys(basket);
@@ -267,7 +275,9 @@ export default function AddPropertiesClient({
{data.postcode}
- {data.candidates.length}{" "}
+ {needle
+ ? `${visible.length} of ${data.candidates.length}`
+ : data.candidates.length}{" "}
{data.candidates.length === 1 ? "address" : "addresses"}
{addable.length > 0 && (
@@ -307,10 +317,40 @@ export default function AddPropertiesClient({
+ {/* Long postcodes can return ~100 addresses — a filter lets the user
+ jump to a house number or street name without scrolling. */}
+ {data.candidates.length > 8 && (
+
+
+ setFilter(e.target.value)}
+ placeholder="Filter these addresses…"
+ spellCheck={false}
+ autoComplete="off"
+ className="w-full border border-slate-200 rounded-xl pl-9 pr-9 py-2 text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/10"
+ />
+ {filter && (
+ setFilter("")}
+ className="absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm leading-none hover:text-slate-700"
+ >
+ ✕
+
+ )}
+
+ )}
+
{/* Long postcodes can return ~100 addresses — scroll inside the card
rather than growing the page. */}
- {data.candidates.map((c) => {
+ {visible.length === 0 ? (
+
+ No addresses match “{filter.trim()}”.
+
+ ) : (
+ visible.map((c) => {
const { label, note } = describeCandidate(c);
const disabled = !c.selectable || c.alreadyInPortfolio;
const isSelected = !!selected[c.uprn];
@@ -361,7 +401,8 @@ export default function AddPropertiesClient({
);
- })}
+ })
+ )}
)}
diff --git a/src/app/portfolio/[slug]/utils.ts b/src/app/portfolio/[slug]/utils.ts
index 6014cc25..745a0e4f 100644
--- a/src/app/portfolio/[slug]/utils.ts
+++ b/src/app/portfolio/[slug]/utils.ts
@@ -25,12 +25,25 @@ import {
totalFloorAreaSql,
lodgementDateSql,
isExpiredSql,
- mainfuelSql,
effectiveSapSql,
effectiveEpcBandSql,
lodgedEpcBandSql,
lodgedSapSql,
provenanceSignalSql,
+ propertyTypeOverrideJoin,
+ resolvedPropertyTypeSql,
+ builtFormOverrideJoin,
+ resolvedBuiltFormSql,
+ constructionAgeOverrideJoin,
+ resolvedConstructionAgeSql,
+ mainFuelOverrideJoin,
+ resolvedMainFuelSql,
+ wallTypeOverrideJoin,
+ resolvedWallTypeSql,
+ roofTypeOverrideJoin,
+ resolvedRoofTypeSql,
+ mainHeatingOverrideJoin,
+ resolvedHeatingSystemSql,
} from "@/lib/services/epcSources";
import {
FilterGroups,
@@ -38,18 +51,19 @@ import {
PropertyFilter,
PROPERTY_TYPE_OPTIONS,
BUILT_FORM_OPTIONS,
- TENURE_OPTIONS,
YEAR_BUILT_OPTIONS,
MAINFUEL_OPTIONS,
PROVENANCE_OPTIONS,
EnumOption,
+ DESCRIPTOR_FILTER_CONFIG,
+ DescriptorBucket,
+ DescriptorMatch,
} from "@/app/utils/propertyFilters";
import { EPC_TO_SAP_MIN, EPC_TO_SAP_MAX } from "@/app/utils/epc";
const ENUM_FIELD_DB_OPTIONS: Record
= {
propertyType: PROPERTY_TYPE_OPTIONS,
builtForm: BUILT_FORM_OPTIONS,
- tenure: TENURE_OPTIONS,
yearBuilt: YEAR_BUILT_OPTIONS,
provenance: PROVENANCE_OPTIONS,
mainfuel: MAINFUEL_OPTIONS,
@@ -508,6 +522,50 @@ function buildEpcSapCondition(
return null;
}
+/** An ILIKE pattern for a needle: prefix ("cavity%") or substring ("%mains gas%"). */
+function descriptorLikePattern(needle: string, match: DescriptorMatch): string {
+ return match === "prefix" ? `${needle}%` : `%${needle}%`;
+}
+
+/**
+ * WHERE fragment matching the free-text wall/roof/heating column against the
+ * selected coarse buckets (mirrors classifyDescriptor). A non-empty bucket
+ * matches any of its needles; the "Unknown" bucket matches the complement —
+ * rows matching NO known needle (which includes the resolved 'Unknown'
+ * terminal). NULL is impossible here (resolvedXSql COALESCEs to 'Unknown').
+ */
+function buildDescriptorBucketCondition(
+ col: ReturnType,
+ buckets: DescriptorBucket[],
+ match: DescriptorMatch,
+ selectedLabels: string[],
+): ReturnType | null {
+ const allNeedles = buckets.flatMap((b) => b.needles);
+ const parts: ReturnType[] = [];
+
+ for (const label of selectedLabels) {
+ const bucket = buckets.find((b) => b.label === label);
+ if (!bucket) continue;
+ if (bucket.needles.length === 0) {
+ // "Unknown" = the complement of every known needle.
+ if (allNeedles.length === 0) return null;
+ const nots = allNeedles.map(
+ (n) => sql`${col} NOT ILIKE ${descriptorLikePattern(n, match)}`,
+ );
+ parts.push(sql`(${sql.join(nots, sql` AND `)})`);
+ } else {
+ const likes = bucket.needles.map(
+ (n) => sql`${col} ILIKE ${descriptorLikePattern(n, match)}`,
+ );
+ parts.push(sql`(${sql.join(likes, sql` OR `)})`);
+ }
+ }
+
+ if (parts.length === 0) return null;
+ if (parts.length === 1) return parts[0];
+ return sql`(${sql.join(parts, sql` OR `)})`;
+}
+
function buildConditionSql(filter: PropertyFilter): ReturnType | null {
switch (filter.field) {
case "address":
@@ -579,7 +637,6 @@ function buildConditionSql(filter: PropertyFilter): ReturnType | nul
case "propertyType":
case "builtForm":
- case "tenure":
case "yearBuilt":
case "provenance":
case "mainfuel": {
@@ -595,14 +652,15 @@ function buildConditionSql(filter: PropertyFilter): ReturnType | nul
const options = ENUM_FIELD_DB_OPTIONS[filter.field];
const colMap: Record> = {
- propertyType: sql`p.property_type`,
- builtForm: sql`p.built_form`,
- tenure: sql`p.tenure`,
- yearBuilt: sql`p.year_built`,
+ // Override-resolved to match the column + the Run filter (ADR-0012).
+ propertyType: resolvedPropertyTypeSql,
+ builtForm: resolvedBuiltFormSql,
+ yearBuilt: resolvedConstructionAgeSql,
provenance: provenanceSignalSql,
- // GAP: new-approach properties have no main-fuel string → NULL, so they
- // only match the "no value" filter branch. See epcSources.ts.
- mainfuel: mainfuelSql(sql`epc`),
+ // Override-resolved (ADR-0012): the new EPC graph has no main fuel, so a
+ // new-approach property matches a fuel filter only via a landlord override;
+ // otherwise it resolves to 'Unknown'.
+ mainfuel: resolvedMainFuelSql(sql`epc`),
};
const col = colMap[filter.field];
@@ -656,6 +714,68 @@ function buildConditionSql(filter: PropertyFilter): ReturnType | nul
if (filter.operator === "num_equals") return sql`${carbon} = ${n}`;
return null;
}
+
+ case "tags": {
+ // Value is a JSON array of selected tag ids, optionally with the synthetic
+ // "__untagged__" bucket. Any-of within tags (ADR-0013). EXISTS on
+ // property_tag is PK-indexed by property_id — no join to add to the count.
+ if (filter.operator !== "enum_one_of") return null;
+ let selected: string[];
+ try {
+ selected = JSON.parse(filter.value);
+ } catch {
+ return null;
+ }
+ if (selected.length === 0) return null;
+
+ const untagged = selected.includes("__untagged__");
+ const ids = selected.filter((s) => /^\d+$/.test(s));
+ const parts: ReturnType[] = [];
+ if (ids.length > 0) {
+ const placeholders = ids.map((id) => sql`${id}::bigint`);
+ parts.push(
+ sql`EXISTS (SELECT 1 FROM property_tag pt WHERE pt.property_id = p.id AND pt.tag_id IN (${sql.join(placeholders, sql`, `)}))`,
+ );
+ }
+ if (untagged) {
+ parts.push(
+ sql`NOT EXISTS (SELECT 1 FROM property_tag pt WHERE pt.property_id = p.id)`,
+ );
+ }
+ if (parts.length === 0) return null;
+ if (parts.length === 1) return parts[0];
+ return sql`(${sql.join(parts, sql` OR `)})`;
+ }
+
+ case "wallType":
+ case "roofType":
+ case "heatingSystem": {
+ // Free-text descriptors: bucket the resolved value by prefix/substring
+ // needles (ADR-0012), mirroring classifyDescriptor. The resolved SQL folds
+ // override → EPC element description → legacy → 'Unknown'.
+ if (filter.operator !== "enum_one_of") return null;
+
+ let selectedLabels: string[];
+ try {
+ selectedLabels = JSON.parse(filter.value);
+ } catch {
+ return null;
+ }
+ if (selectedLabels.length === 0) return null;
+
+ const { buckets, match } = DESCRIPTOR_FILTER_CONFIG[filter.field];
+ const colMap: Record> = {
+ wallType: resolvedWallTypeSql(sql`epc`),
+ roofType: resolvedRoofTypeSql(sql`epc`),
+ heatingSystem: resolvedHeatingSystemSql(sql`epc`),
+ };
+ return buildDescriptorBucketCondition(
+ colMap[filter.field],
+ buckets,
+ match,
+ selectedLabels,
+ );
+ }
}
return null;
}
@@ -695,6 +815,15 @@ const EPC_JOIN_FILTER_FIELDS = new Set([
"floorArea",
"epcExpiryDate",
"mainfuel",
+ // Override-resolved (ADR-0012): needs the EPC graph joins + the override join.
+ "propertyType",
+ "builtForm",
+ "yearBuilt",
+ // Free-text descriptors (ADR-0012): resolved SQL reads the EPC element
+ // description subquery + the override join.
+ "wallType",
+ "roofType",
+ "heatingSystem",
]);
const PLAN_JOIN_FILTER_FIELDS = new Set(["expectedEpc"]);
@@ -720,7 +849,14 @@ export async function getPropertiesCount(
const epcJoins = needsEpcJoins
? sql`LEFT JOIN property_details_epc epc ON epc.property_id = p.id
- ${newApproachJoins}`
+ ${newApproachJoins}
+ ${propertyTypeOverrideJoin}
+ ${builtFormOverrideJoin}
+ ${constructionAgeOverrideJoin}
+ ${mainFuelOverrideJoin}
+ ${wallTypeOverrideJoin}
+ ${roofTypeOverrideJoin}
+ ${mainHeatingOverrideJoin}`
: sql``;
const planJoin = needsPlanJoin
? sql`LEFT JOIN LATERAL (
@@ -739,12 +875,58 @@ export async function getPropertiesCount(
${epcJoins}
${planJoin}
WHERE p.portfolio_id = ${portfolioId}
+ -- Unmatched (no-UPRN) properties live in the "Needs attention" tab until
+ -- resolved, so they're excluded from the main table + its count.
+ AND p.uprn IS NOT NULL
${combinedWhere}
`);
return parseInt(result.rows[0]?.count ?? "0", 10);
}
+/**
+ * The ids of every Property matching a filter selection — used by filter-driven
+ * Bulk tag assignment ("tag all N matching the current filter", ADR-0013). Same
+ * resolution + conditional joins as getPropertiesCount, but returns ids across
+ * the whole matching set, not a display page. Mirrors the table's `uprn IS NOT
+ * NULL` exclusion so the count the user saw and the set that gets tagged agree.
+ */
+export async function getFilteredPropertyIds(
+ portfolioId: string,
+ filterGroups: FilterGroups = [],
+): Promise {
+ const combinedWhere = buildWhereClause(filterGroups);
+ const fields = filterFieldsInUse(filterGroups);
+ const needsEpcJoins = [...fields].some((f) => EPC_JOIN_FILTER_FIELDS.has(f));
+ const needsPlanJoin = [...fields].some((f) => PLAN_JOIN_FILTER_FIELDS.has(f));
+
+ const epcJoins = needsEpcJoins
+ ? sql`LEFT JOIN property_details_epc epc ON epc.property_id = p.id
+ ${newApproachJoins}`
+ : sql``;
+ const planJoin = needsPlanJoin
+ ? sql`LEFT JOIN LATERAL (
+ SELECT id, post_sap_points FROM plan
+ WHERE property_id = p.id
+ AND portfolio_id = p.portfolio_id
+ AND is_default = true
+ ORDER BY created_at DESC
+ LIMIT 1
+ ) pl ON true`
+ : sql``;
+
+ const result = await db.execute<{ id: string }>(sql`
+ SELECT DISTINCT p.id AS id
+ FROM property p
+ ${epcJoins}
+ ${planJoin}
+ WHERE p.portfolio_id = ${portfolioId}
+ AND p.uprn IS NOT NULL
+ ${combinedWhere}
+ `);
+ return result.rows.map((r) => BigInt(r.id));
+}
+
export async function getProperties(
portfolioId: string,
limit: number = 1000,
@@ -786,16 +968,39 @@ export async function getProperties(
COALESCE(rec.cost, 0) AS "totalRecommendationCost",
p.landlord_property_id AS "landlordPropertyId",
p.original_sap_points AS "originalSapPoints",
- p.property_type AS "propertyType",
- p.built_form AS "builtForm",
- p.tenure AS tenure,
- p.year_built AS "yearBuilt",
+ -- Property Type is resolved through the landlord-override precedence
+ -- (override → EPC-derived → 'Unknown'), matching the modelling Run filter.
+ -- See resolvePropertyType / ADR-0012.
+ ${resolvedPropertyTypeSql} AS "propertyType",
+ ${resolvedBuiltFormSql} AS "builtForm",
+ -- Construction Age is band-native and override-resolved (ADR-0012); the
+ -- "yearBuilt" key is retained to avoid a wide rename. See resolveConstructionAge.
+ ${resolvedConstructionAgeSql} AS "yearBuilt",
${lodgementDateSql(sql`epc`)}::text AS "epcLodgementDate",
${isExpiredSql(sql`epc`)} AS "epcIsExpired",
${totalFloorAreaSql(sql`epc`)} AS "totalFloorArea",
${carbonSql(sql`epc`)} AS "co2Emissions",
- ${mainfuelSql(sql`epc`)} AS mainfuel,
- p.lexiscore AS lexiscore
+ -- Main Fuel: override → EPC-derived → 'Unknown'. The new EPC graph has no
+ -- main fuel, so overrides are the only new-approach source (ADR-0012).
+ ${resolvedMainFuelSql(sql`epc`)} AS mainfuel,
+ -- Wall / roof / heating: override → EPC element description → legacy → 'Unknown'
+ -- (ADR-0012). Per-part components (wall/roof) read the main building part.
+ ${resolvedWallTypeSql(sql`epc`)} AS "wallType",
+ ${resolvedRoofTypeSql(sql`epc`)} AS "roofType",
+ ${resolvedHeatingSystemSql(sql`epc`)} AS "heatingSystem",
+ p.lexiscore AS lexiscore,
+ -- Portfolio Tags on this property, name-ordered, as JSON (ADR-0013). A
+ -- correlated subquery keeps the main query at one row per property (a JOIN
+ -- would multiply rows and break the LATERAL aggregates above).
+ COALESCE((
+ SELECT json_agg(
+ json_build_object('id', t.id::text, 'name', t.name, 'colour', t.colour)
+ ORDER BY t.name
+ )
+ FROM property_tag pt
+ JOIN portfolio_tag t ON t.id = pt.tag_id
+ WHERE pt.property_id = p.id
+ ), '[]'::json) AS tags
FROM property p
-- LATERAL one-row lookups keep this query at "N properties × index probe"
-- instead of hash-joining the multi-million-row plan/recommendation tables.
@@ -830,7 +1035,17 @@ export async function getProperties(
LEFT JOIN property_details_epc epc
ON epc.property_id = p.id
${newApproachJoins}
+ ${propertyTypeOverrideJoin}
+ ${builtFormOverrideJoin}
+ ${constructionAgeOverrideJoin}
+ ${mainFuelOverrideJoin}
+ ${wallTypeOverrideJoin}
+ ${roofTypeOverrideJoin}
+ ${mainHeatingOverrideJoin}
WHERE p.portfolio_id = ${portfolioId}
+ -- Unmatched (no-UPRN) properties live in the "Needs attention" tab until
+ -- resolved, so they're excluded from the main table.
+ AND p.uprn IS NOT NULL
${combinedWhere}
LIMIT ${limit} OFFSET ${offset};
`);
diff --git a/src/app/utils/propertyFilters.ts b/src/app/utils/propertyFilters.ts
index 1f85675e..56b178a6 100644
--- a/src/app/utils/propertyFilters.ts
+++ b/src/app/utils/propertyFilters.ts
@@ -8,12 +8,15 @@ export type FilterField =
| "propertyRef"
| "propertyType"
| "builtForm"
- | "tenure"
| "yearBuilt"
| "provenance"
| "floorArea"
| "co2Emissions"
- | "mainfuel";
+ | "mainfuel"
+ | "wallType"
+ | "roofType"
+ | "heatingSystem"
+ | "tags";
export type FilterOperator =
| "contains"
@@ -64,13 +67,23 @@ export interface EnumOption {
dbValues: string[];
}
+// dbValues are the label vocabulary emitted by resolvedPropertyTypeSql (override
+// snapshot / EPC-derived label). "Park home" is reachable from an RdSAP code (4)
+// or an override; "Unknown" is the never-null terminal + an explicit override —
+// it selects properties with no resolvable value at all (ADR-0012).
export const PROPERTY_TYPE_OPTIONS: EnumOption[] = [
{ label: "House", dbValues: ["House"] },
{ label: "Flat", dbValues: ["Flat"] },
{ label: "Bungalow", dbValues: ["Bungalow"] },
{ label: "Maisonette", dbValues: ["Maisonette"] },
+ { label: "Park home", dbValues: ["Park home"] },
+ { label: "Unknown", dbValues: ["Unknown"] },
];
+// dbValues are the label vocabulary emitted by resolvedBuiltFormSql (override
+// snapshot / EPC-derived label). "Not Recorded" matches only an explicit
+// override of that literal; "Unknown" is the never-null terminal + an explicit
+// override — it selects properties with no resolvable value at all (ADR-0012).
export const BUILT_FORM_OPTIONS: EnumOption[] = [
{ label: "Detached", dbValues: ["Detached"] },
{ label: "Semi-Detached", dbValues: ["Semi-Detached"] },
@@ -79,15 +92,7 @@ export const BUILT_FORM_OPTIONS: EnumOption[] = [
{ label: "Enclosed End-Terrace", dbValues: ["Enclosed End-Terrace"] },
{ label: "Enclosed Mid-Terrace", dbValues: ["Enclosed Mid-Terrace"] },
{ label: "Not Recorded", dbValues: ["Not Recorded"] },
-];
-
-export const TENURE_OPTIONS: EnumOption[] = [
- { label: "Owner-occupied", dbValues: ["Owner-occupied", "owner-occupied"] },
- { label: "Rented (Private)", dbValues: ["Rented (private)", "rental (private)", "rented (private)"] },
- { label: "Rented (Social)", dbValues: ["Rented (social)", "rental (social)"] },
- { label: "Not Defined", dbValues: ["Not defined - use in the case of a new dwelling for which the intended tenure in not known. It is not to be used for an existing dwelling"] },
- { label: "Unknown", dbValues: ["unknown"] },
- { label: "Not Recorded", dbValues: ["__null__"] },
+ { label: "Unknown", dbValues: ["Unknown"] },
];
// Provenance signal (ADR-0002). dbValues are the raw signal strings emitted by
@@ -98,26 +103,210 @@ export const PROVENANCE_OPTIONS: EnumOption[] = [
{ label: "Standard", dbValues: ["none"] },
];
+// Construction Age is band-native (ADR-0012): labels + dbValues are the RdSAP
+// band labels emitted by resolvedConstructionAgeSql. These MUST match
+// CONSTRUCTION_AGE_BANDS[*].label in epcSources.ts exactly (note the en-dash);
+// epcSources.test.ts guards against drift. "Unknown" is the never-null terminal.
export const YEAR_BUILT_OPTIONS: EnumOption[] = [
- "1900","1930","1950","1967","1976","1983","1991","1996",
- "2003","2007","2008","2009","2010","2011","2012","2013",
- "2014","2015","2016","2017","2018","2019","2020","2021",
- "2022","2023","2024","2025",
-].map((y) => ({ label: y, dbValues: [y] }));
+ "before 1900", "1900–1929", "1930–1949", "1950–1966", "1967–1975",
+ "1976–1982", "1983–1990", "1991–1995", "1996–2002", "2003–2006",
+ "2007–2011", "2012–2022", "2023 onwards", "Unknown",
+].map((label) => ({ label, dbValues: [label] }));
-export const MAINFUEL_OPTIONS: EnumOption[] = [
- { label: "Mains Gas", dbValues: ["Gas mains gas", "Mains gas community", "Mains gas not community", "Mains gas this is for backwards compatibility only and should not be used"] },
- { label: "LPG", dbValues: ["Bottled lpg", "Lpg community", "Lpg not community", "Lpg this is for backwards compatibility only and should not be used"] },
- { label: "Oil", dbValues: ["Oil heating oil", "Oil community", "Oil not community", "Oil this is for backwards compatibility only and should not be used"] },
- { label: "Electricity", dbValues: ["Electricity electricity unspecified tariff", "Electricity community", "Electricity not community", "Electricity this is for backwards compatibility only and should not be used"] },
- { label: "Biomass", dbValues: ["Bulk wood pellets", "Wood chips", "Wood logs", "Biomass community", "Biomass this is for backwards compatibility only and should not be used"] },
- { label: "Coal", dbValues: ["Anthracite", "House coal not community", "House coal this is for backwards compatibility only and should not be used", "Smokeless coal", "Coal community"] },
- { label: "Dual Fuel (Mineral + Wood)", dbValues: ["Dual fuel mineral wood"] },
+// RdSAP `main_fuel` code → coarse label. The new EPC graph stores the main fuel
+// as this numeric code on epc_main_heating_detail.main_fuel_type (see mainfuelSql
+// / resolveMainFuel), so every code that can appear must fold into a filter
+// option or an overridden/EPC-derived fuel would display but be unfilterable
+// (ADR-0012). Codes are the authoritative Model `epc_codes.csv` `main_fuel` table
+// (RdSAP), cross-checked against production epc rows: 26→mains gas, 29/39→electric,
+// 0/20/25/31/57→"Community scheme", 5/15/33→coal, 6→wood logs, 9→dual fuel. All
+// "(community)"/heat-network codes bucket to "Community Heat Network" — being on a
+// communal scheme is the salient fact; the scheme's own fuel is a secondary detail.
+export const RDSAP_MAIN_FUEL_CODE_LABELS: Record = {
+ // Mains gas
+ "1": "Mains Gas", "26": "Mains Gas",
+ // LPG
+ "2": "LPG", "3": "LPG", "17": "LPG", "27": "LPG", "38": "LPG",
+ // Oil
+ "4": "Oil", "28": "Oil",
+ // Electricity
+ "10": "Electricity", "29": "Electricity", "39": "Electricity",
+ // Coal / mineral solid fuel (anthracite, smokeless, house coal)
+ "5": "Coal", "14": "Coal", "15": "Coal", "33": "Coal",
+ // Biomass / wood (logs, pellets, chips)
+ "6": "Biomass", "7": "Biomass", "8": "Biomass", "12": "Biomass", "16": "Biomass",
+ // Dual fuel
+ "9": "Dual Fuel (Mineral + Wood)",
+ // Biogas
+ "13": "Biogas", "51": "Biogas",
+ // Bioethanol
+ "19": "Bioethanol", "76": "Bioethanol",
+ // Biodiesel (from biomass / used cooking oil / vegetable / rape seed oil)
+ "34": "Biodiesel", "35": "Biodiesel", "36": "Biodiesel", "37": "Biodiesel",
+ "71": "Biodiesel", "72": "Biodiesel", "73": "Biodiesel", "74": "Biodiesel",
+ // Biodiesel blend
+ "18": "B30k (Biodiesel blend)", "75": "B30k (Biodiesel blend)",
+ // Waste combustion
+ "11": "Waste Combustion",
+ // Community / heat-network (the dwelling is on a communal scheme)
+ "0": "Community Heat Network", "20": "Community Heat Network", "21": "Community Heat Network",
+ "22": "Community Heat Network", "23": "Community Heat Network", "24": "Community Heat Network",
+ "25": "Community Heat Network", "30": "Community Heat Network", "31": "Community Heat Network",
+ "32": "Community Heat Network", "41": "Community Heat Network", "42": "Community Heat Network",
+ "43": "Community Heat Network", "44": "Community Heat Network", "45": "Community Heat Network",
+ "46": "Community Heat Network", "47": "Community Heat Network", "48": "Community Heat Network",
+ "49": "Community Heat Network", "50": "Community Heat Network", "52": "Community Heat Network",
+ "53": "Community Heat Network", "54": "Community Heat Network", "55": "Community Heat Network",
+ "56": "Community Heat Network", "57": "Community Heat Network", "58": "Community Heat Network",
+ "99": "Community Heat Network",
+};
+
+// EPR free-text main_fuel_type strings (Elmhurst/PASHub, ~5% of new-approach
+// rows) folded to the same labels. The empty-string sentinel is NULLIF'd to NULL
+// upstream and resolves to 'Unknown'.
+export const EPR_MAIN_FUEL_STRING_LABELS: Record = {
+ "Mains gas": "Mains Gas",
+ "Electricity": "Electricity",
+ "Bulk LPG": "LPG",
+ "Heating oil": "Oil",
+};
+
+// dbValues fold several vocabularies onto one user-facing label: the raw legacy
+// EPC mainfuel strings (property_details_epc), the landlord main_fuel override
+// values ("mains gas", "LPG (bulk)", … — see MainFuelValues), the new-approach
+// RdSAP numeric codes (RDSAP_MAIN_FUEL_CODE_LABELS) and the EPR strings
+// (EPR_MAIN_FUEL_STRING_LABELS). resolvedMainFuelSql emits whichever applies; all
+// must resolve to the same chip (ADR-0012). descriptorResolution.test asserts
+// every override value, RdSAP code and EPR string is covered here.
+const MAINFUEL_OPTIONS_BASE: EnumOption[] = [
+ { label: "Mains Gas", dbValues: ["Gas mains gas", "Mains gas community", "Mains gas not community", "Mains gas this is for backwards compatibility only and should not be used", "mains gas", "mains gas (community)"] },
+ { label: "LPG", dbValues: ["Bottled lpg", "Lpg community", "Lpg not community", "Lpg this is for backwards compatibility only and should not be used", "LPG (bulk)", "bottled LPG", "LPG special condition"] },
+ { label: "Oil", dbValues: ["Oil heating oil", "Oil community", "Oil not community", "Oil this is for backwards compatibility only and should not be used", "oil"] },
+ { label: "Electricity", dbValues: ["Electricity electricity unspecified tariff", "Electricity community", "Electricity not community", "Electricity this is for backwards compatibility only and should not be used", "electricity", "electricity (community)"] },
+ { label: "Biomass", dbValues: ["Bulk wood pellets", "Wood chips", "Wood logs", "Biomass community", "Biomass this is for backwards compatibility only and should not be used", "biomass (community)", "wood logs"] },
+ { label: "Coal", dbValues: ["Anthracite", "House coal not community", "House coal this is for backwards compatibility only and should not be used", "Smokeless coal", "Coal community", "house coal", "smokeless coal"] },
+ { label: "Dual Fuel (Mineral + Wood)", dbValues: ["Dual fuel mineral wood", "dual fuel (mineral and wood)"] },
{ label: "Biogas", dbValues: ["Biogas not community"] },
+ { label: "Bioethanol", dbValues: [] },
{ label: "Biodiesel", dbValues: ["Heat from boilers using biodiesel from any biomass source community"] },
{ label: "B30d (Biodiesel blend)", dbValues: ["B30d community"] },
{ label: "B30k (Biodiesel blend)", dbValues: ["B30k not community"] },
+ { label: "Waste Combustion", dbValues: [] },
{ label: "Community Heat Network", dbValues: ["From heat network data community"] },
{ label: "No Heating System", dbValues: ["To be used only when there is no heatinghotwater system", "To be used only when there is no heatinghotwater system or data is from a community network"] },
- { label: "Unknown / No Data", dbValues: ["UNKNOWN", "NO DATA!"] },
+ { label: "Unknown / No Data", dbValues: ["UNKNOWN", "NO DATA!", "Unknown"] },
];
+
+/** Fold the RdSAP code + EPR string vocabularies into each label's dbValues. */
+export const MAINFUEL_OPTIONS: EnumOption[] = MAINFUEL_OPTIONS_BASE.map((opt) => {
+ const codes = Object.entries(RDSAP_MAIN_FUEL_CODE_LABELS)
+ .filter(([, label]) => label === opt.label)
+ .map(([code]) => code);
+ const strings = Object.entries(EPR_MAIN_FUEL_STRING_LABELS)
+ .filter(([, label]) => label === opt.label)
+ .map(([str]) => str);
+ return { ...opt, dbValues: [...opt.dbValues, ...codes, ...strings] };
+});
+
+/* -----------------------------------------------------------------------
+ Free-text descriptor buckets: Wall Type / Roof Type / Heating System (ADR-0012)
+
+ Unlike the enum fields above (exact dbValues), the resolved wall/roof/heating
+ value is a free-text description (override vocabulary, EPC
+ epc_energy_element.description, or legacy property_details_epc column) with
+ HIGH cardinality — 88+ distinct EPC wall descriptions, 245 legacy, plus
+ insulation-thickness variants, "Average thermal transmittance …" U-values and
+ encoding corruption. Exact matching can't scale, so each coarse bucket is a set
+ of case-insensitive NEEDLES matched by prefix (wall/roof) or substring
+ (heating, whose fuel follows a comma). classifyDescriptor is the pure twin of
+ the SQL bucketing in the portfolio query's buildConditionSql — keep in sync.
+ Ordering matters: the first bucket whose needle matches wins.
+------------------------------------------------------------------------ */
+
+export interface DescriptorBucket {
+ label: string;
+ /** Lowercase needles, matched per the field's DescriptorMatch mode. Empty = the Unknown terminal (matches the complement). */
+ needles: string[];
+}
+
+export type DescriptorMatch = "prefix" | "contains";
+
+// Wall construction. Prefix-matched on the leading construction term. "Stone"
+// folds sandstone/limestone + granite/whinstone; "Average thermal transmittance …"
+// (a U-value, not a construction type) and corruption fall through to Unknown.
+export const WALL_TYPE_OPTIONS: DescriptorBucket[] = [
+ { label: "Cavity", needles: ["cavity"] },
+ { label: "Solid Brick", needles: ["solid brick"] },
+ { label: "Timber Frame", needles: ["timber frame"] },
+ { label: "Stone", needles: ["sandstone", "granite"] },
+ { label: "System Built", needles: ["system built"] },
+ { label: "Park Home", needles: ["park home"] },
+ { label: "Cob", needles: ["cob"] },
+ { label: "Curtain Wall", needles: ["curtain"] },
+ { label: "Basement", needles: ["basement"] },
+ { label: "Unknown", needles: [] },
+];
+
+// Roof form. Prefix-matched. "Premises Above" folds the "(another dwelling
+// above)" / "(other premises above)" family (a flat with a dwelling above it, so
+// no own roof). U-values fall through to Unknown.
+export const ROOF_TYPE_OPTIONS: DescriptorBucket[] = [
+ { label: "Pitched", needles: ["pitched"] },
+ { label: "Flat", needles: ["flat"] },
+ { label: "Room-in-Roof", needles: ["roof room"] },
+ { label: "Thatched", needles: ["thatched"] },
+ { label: "Premises Above", needles: ["(another", "(other", "(same", "another dwelling", "another premises", "other premises"] },
+ { label: "Unknown", needles: [] },
+];
+
+// Heating system. Substring-matched (the fuel follows a comma, e.g. "Boiler and
+// radiators, mains gas"). Order is load-bearing: Heat Pump / Community / Solid
+// Fuel / Oil / LPG are checked before the gas + electric buckets so a
+// heat-pump/community/wood/oil/LPG system isn't miscaught by "gas"/"electric";
+// Gas Room Heater before Gas Boiler; Electric Storage before Direct Electric.
+export const HEATING_SYSTEM_OPTIONS: DescriptorBucket[] = [
+ { label: "Heat Pump", needles: ["heat pump"] },
+ { label: "Community", needles: ["community"] },
+ { label: "Solid Fuel", needles: ["coal", "anthracite", "smokeless", "wood", "dual fuel", "biomass", "solid fuel"] },
+ // NB: bare "oil" is a substring of "b(oil)er" — match the fuel token only (", oil"
+ // as in "Boiler and radiators, oil") and the leading override "Oil room heater".
+ { label: "Oil", needles: [", oil", "oil room heater"] },
+ { label: "LPG", needles: ["lpg"] },
+ { label: "Gas Room Heater", needles: ["gas room heater", "room heaters, mains gas", "room heaters, gas"] },
+ { label: "Gas Boiler", needles: ["mains gas", "gas boiler", "gas cpsu"] },
+ { label: "Electric Storage", needles: ["storage heater"] },
+ { label: "Direct Electric", needles: ["electric"] },
+ { label: "Unknown", needles: [] },
+];
+
+/** Filter config per descriptor field: its buckets + how needles are matched. */
+export const DESCRIPTOR_FILTER_CONFIG: Record<
+ "wallType" | "roofType" | "heatingSystem",
+ { buckets: DescriptorBucket[]; match: DescriptorMatch }
+> = {
+ wallType: { buckets: WALL_TYPE_OPTIONS, match: "prefix" },
+ roofType: { buckets: ROOF_TYPE_OPTIONS, match: "prefix" },
+ heatingSystem: { buckets: HEATING_SYSTEM_OPTIONS, match: "contains" },
+};
+
+/**
+ * Classify a resolved free-text descriptor into its coarse filter bucket: the
+ * first bucket with a matching needle, else "Unknown". Pure twin of the SQL
+ * bucketing in buildConditionSql (portfolio query) — keep in sync.
+ */
+export function classifyDescriptor(
+ value: string | null | undefined,
+ buckets: DescriptorBucket[],
+ match: DescriptorMatch,
+): string {
+ if (value == null) return "Unknown";
+ const v = value.toLowerCase();
+ for (const bucket of buckets) {
+ for (const needle of bucket.needles) {
+ if (match === "prefix" ? v.startsWith(needle) : v.includes(needle)) {
+ return bucket.label;
+ }
+ }
+ }
+ return "Unknown";
+}
diff --git a/src/lib/bulkDocumentDownload/model.test.ts b/src/lib/bulkDocumentDownload/model.test.ts
new file mode 100644
index 00000000..c2d9d007
--- /dev/null
+++ b/src/lib/bulkDocumentDownload/model.test.ts
@@ -0,0 +1,193 @@
+import { describe, expect, it } from "vitest";
+import {
+ MAX_BULK_DOWNLOAD_PROPERTIES,
+ buildBulkDownloadRecord,
+ buildSelectionConfig,
+ bulkDownloadRefetchInterval,
+ parseDelivery,
+} from "./model";
+
+describe("buildSelectionConfig — UI selection → stored config", () => {
+ const portfolioId = 814;
+
+ it("one project + include all → project_codes", () => {
+ const r = buildSelectionConfig({
+ scope: { kind: "project", projectCode: "ABRI-2024-01" },
+ includeAll: true,
+ landlordPropertyIds: [],
+ portfolioId,
+ });
+ expect(r).toEqual({
+ ok: true,
+ config: { project_codes: ["ABRI-2024-01"], portfolio_id: 814 },
+ });
+ });
+
+ it("one project + ticked subset → landlord_property_ids (scope ignored)", () => {
+ const r = buildSelectionConfig({
+ scope: { kind: "project", projectCode: "ABRI-2024-01" },
+ includeAll: false,
+ landlordPropertyIds: ["LP1023", "LP1044"],
+ portfolioId,
+ });
+ expect(r).toEqual({
+ ok: true,
+ config: { landlord_property_ids: ["LP1023", "LP1044"], portfolio_id: 814 },
+ });
+ });
+
+ it("all projects + include all → every project code", () => {
+ const r = buildSelectionConfig({
+ scope: { kind: "all-projects", projectCodes: ["A-1", "B-2"] },
+ includeAll: true,
+ landlordPropertyIds: [],
+ portfolioId,
+ });
+ expect(r).toEqual({
+ ok: true,
+ config: { project_codes: ["A-1", "B-2"], portfolio_id: 814 },
+ });
+ });
+
+ it("all projects + ticked subset → landlord_property_ids", () => {
+ const r = buildSelectionConfig({
+ scope: { kind: "all-projects", projectCodes: ["A-1", "B-2"] },
+ includeAll: false,
+ landlordPropertyIds: ["LP1"],
+ portfolioId,
+ });
+ expect(r).toEqual({
+ ok: true,
+ config: { landlord_property_ids: ["LP1"], portfolio_id: 814 },
+ });
+ });
+
+ it("de-duplicates ids and codes", () => {
+ expect(
+ buildSelectionConfig({
+ scope: { kind: "all-projects", projectCodes: ["A-1", "A-1"] },
+ includeAll: true,
+ landlordPropertyIds: [],
+ portfolioId,
+ }),
+ ).toEqual({ ok: true, config: { project_codes: ["A-1"], portfolio_id: 814 } });
+
+ expect(
+ buildSelectionConfig({
+ scope: { kind: "project", projectCode: "A-1" },
+ includeAll: false,
+ landlordPropertyIds: ["LP1", "LP1", " LP1 "],
+ portfolioId,
+ }),
+ ).toEqual({
+ ok: true,
+ config: { landlord_property_ids: ["LP1"], portfolio_id: 814 },
+ });
+ });
+
+ it("rejects an empty subset", () => {
+ const r = buildSelectionConfig({
+ scope: { kind: "project", projectCode: "A-1" },
+ includeAll: false,
+ landlordPropertyIds: [],
+ portfolioId,
+ });
+ expect(r.ok).toBe(false);
+ });
+
+ it("rejects include-all with no usable codes", () => {
+ const r = buildSelectionConfig({
+ scope: { kind: "all-projects", projectCodes: ["", " "] },
+ includeAll: true,
+ landlordPropertyIds: [],
+ portfolioId,
+ });
+ expect(r.ok).toBe(false);
+ });
+
+ it("rejects a subset over the 500 cap with the detail message", () => {
+ const ids = Array.from({ length: 501 }, (_, i) => `LP${i}`);
+ const r = buildSelectionConfig({
+ scope: { kind: "project", projectCode: "A-1" },
+ includeAll: false,
+ landlordPropertyIds: ids,
+ portfolioId,
+ });
+ expect(r.ok).toBe(false);
+ if (!r.ok) {
+ expect(r.error).toContain(`over the ${MAX_BULK_DOWNLOAD_PROPERTIES} limit`);
+ expect(r.error).toContain("501 properties");
+ }
+ });
+});
+
+describe("buildBulkDownloadRecord", () => {
+ it("writes the app-owned task marker and the config as JSON inputs", () => {
+ const record = buildBulkDownloadRecord({
+ portfolioId: "814",
+ config: { project_codes: ["A-1"], portfolio_id: 814 },
+ });
+ expect(record.taskSource).toBe("app:bulk_document_download");
+ expect(record.source).toBe("portfolio_id");
+ expect(record.sourceId).toBe("814");
+ expect(record.status).toBe("waiting");
+ expect(JSON.parse(record.inputs)).toEqual({
+ project_codes: ["A-1"],
+ portfolio_id: 814,
+ });
+ });
+});
+
+
+describe("parseDelivery", () => {
+ it("reads a finished delivery", () => {
+ const d = parseDelivery(
+ JSON.stringify({
+ presigned_url: "https://x",
+ package_s3_key: "k",
+ included: 137,
+ skipped: [{ landlord_property_id: "LP9", s3_key: "k", reason: "unreadable" }],
+ }),
+ );
+ expect(d).toEqual({
+ presignedUrl: "https://x",
+ packageS3Key: "k",
+ included: 137,
+ skipped: [{ landlord_property_id: "LP9", s3_key: "k", reason: "unreadable" }],
+ });
+ });
+
+ it("tolerates link-key naming variants", () => {
+ expect(parseDelivery(JSON.stringify({ presignedUrl: "https://a" }))?.presignedUrl).toBe(
+ "https://a",
+ );
+ expect(parseDelivery(JSON.stringify({ download_url: "https://b" }))?.presignedUrl).toBe(
+ "https://b",
+ );
+ expect(parseDelivery(JSON.stringify({ url: "https://c", s3_key: "k" }))).toMatchObject({
+ presignedUrl: "https://c",
+ packageS3Key: "k",
+ });
+ });
+
+ it("returns null for in-flight or malformed outputs", () => {
+ expect(parseDelivery(null)).toBeNull();
+ expect(parseDelivery("")).toBeNull();
+ expect(parseDelivery("{not json")).toBeNull();
+ expect(parseDelivery(JSON.stringify({ included: 0 }))).toBeNull();
+ });
+});
+
+describe("bulkDownloadRefetchInterval", () => {
+ it("polls while preparing, stops once resolved", () => {
+ expect(bulkDownloadRefetchInterval(undefined)).toBe(8_000);
+ expect(bulkDownloadRefetchInterval({ state: "preparing", delivery: null })).toBe(8_000);
+ expect(
+ bulkDownloadRefetchInterval({
+ state: "ready",
+ delivery: { presignedUrl: "x", packageS3Key: null, included: 1, skipped: [] },
+ }),
+ ).toBe(false);
+ expect(bulkDownloadRefetchInterval({ state: "failed", delivery: null })).toBe(false);
+ });
+});
diff --git a/src/lib/bulkDocumentDownload/model.ts b/src/lib/bulkDocumentDownload/model.ts
new file mode 100644
index 00000000..3eee8c60
--- /dev/null
+++ b/src/lib/bulkDocumentDownload/model.ts
@@ -0,0 +1,194 @@
+/**
+ * Bulk-document-download domain model — pure logic for the Documents bulk
+ * download. Mirrors the Modelling-run trigger convention (ADR-0008): one
+ * app-authored `tasks` row whose `inputs` carries the selection config, then
+ * the backend is handed only the task id.
+ *
+ * The backend resolves the union of (all properties in the given project
+ * codes) and (the hand-picked landlord property ids), de-duplicated. Rule of
+ * thumb: "include all" sends `project_codes` (so properties without a
+ * landlord_property_id are still swept in); a ticked subset sends
+ * `landlord_property_ids`. "All projects" enumerates the portfolio's project
+ * codes — there is no server-side "whole portfolio" option by design.
+ */
+
+/** Backend cap; over this the trigger is rejected with a 400. */
+export const MAX_BULK_DOWNLOAD_PROPERTIES = 500;
+
+/**
+ * The selection config, exactly as it is stored (JSON) in `tasks.inputs` and
+ * read back by the worker. snake_case because the backend parses it directly —
+ * do not add app-provenance keys here (the recipient email is resolved from
+ * the JWT at dispatch, not carried in the config).
+ */
+export interface BulkDownloadConfig {
+ /** HubSpot project codes (hubspot_deal_data.project_code). */
+ project_codes?: string[];
+ /** The hand-pick key (property.landlord_property_id). */
+ landlord_property_ids?: string[];
+ /** Names the ZIP only. */
+ portfolio_id?: number;
+}
+
+/** Which projects the download is scoped to. */
+export type BulkDownloadScope =
+ | { kind: "project"; projectCode: string }
+ | { kind: "all-projects"; projectCodes: string[] };
+
+/** The UI's selection intent, resolved into a config server-side. */
+export interface BulkDownloadSelectionInput {
+ scope: BulkDownloadScope;
+ /** true → "include all" (send project_codes); false → send the ticked ids. */
+ includeAll: boolean;
+ /** The ticked landlord_property_ids — used only when includeAll is false. */
+ landlordPropertyIds: string[];
+ portfolioId: number;
+}
+
+export type BuildConfigResult =
+ | { ok: true; config: BulkDownloadConfig }
+ | { ok: false; error: string };
+
+/**
+ * Map the UI selection onto the stored config:
+ * include all → { project_codes, portfolio_id }
+ * ticked subset → { landlord_property_ids, portfolio_id }
+ * At least one of project_codes / landlord_property_ids must be non-empty.
+ */
+export function buildSelectionConfig(
+ input: BulkDownloadSelectionInput,
+): BuildConfigResult {
+ const portfolio_id = input.portfolioId;
+
+ if (input.includeAll) {
+ const rawCodes =
+ input.scope.kind === "project"
+ ? [input.scope.projectCode]
+ : input.scope.projectCodes;
+ const project_codes = [
+ ...new Set(rawCodes.map((c) => c.trim()).filter((c) => c.length > 0)),
+ ];
+ if (project_codes.length === 0) {
+ return { ok: false, error: "Pick at least one project to download." };
+ }
+ return { ok: true, config: { project_codes, portfolio_id } };
+ }
+
+ const landlord_property_ids = [
+ ...new Set(input.landlordPropertyIds.map((i) => i.trim()).filter(Boolean)),
+ ];
+ if (landlord_property_ids.length === 0) {
+ return {
+ ok: false,
+ error: "Tick at least one property, or choose “include all”.",
+ };
+ }
+ if (landlord_property_ids.length > MAX_BULK_DOWNLOAD_PROPERTIES) {
+ return {
+ ok: false,
+ error: `The selection has ${landlord_property_ids.length} properties, over the ${MAX_BULK_DOWNLOAD_PROPERTIES} limit — narrow your selection.`,
+ };
+ }
+ return { ok: true, config: { landlord_property_ids, portfolio_id } };
+}
+
+/**
+ * The marker the worker keys off, in `task_source` (ADR-0011). It receives only
+ * the task id, re-reads this row, and guards on this value before assembling.
+ */
+export const BULK_DOWNLOAD_TASK_SOURCE = "app:bulk_document_download";
+
+/**
+ * The row a bulk download persists: an app-authored task whose `inputs` carries
+ * the selection config. Single marker in `task_source` (ADR-0011) — `service`
+ * is left null; `source`/`source_id` scope it to the Portfolio (and attach it
+ * to the portfolio's logs).
+ */
+export function buildBulkDownloadRecord(args: {
+ portfolioId: string;
+ config: BulkDownloadConfig;
+}): {
+ taskSource: typeof BULK_DOWNLOAD_TASK_SOURCE;
+ source: "portfolio_id";
+ sourceId: string;
+ status: "waiting";
+ inputs: string;
+} {
+ return {
+ taskSource: BULK_DOWNLOAD_TASK_SOURCE,
+ source: "portfolio_id",
+ sourceId: args.portfolioId,
+ status: "waiting",
+ inputs: JSON.stringify(args.config),
+ };
+}
+
+// ── Delivery / status (optional in-app polling) ──────────────────────────────
+
+export interface BulkDownloadSkipped {
+ landlord_property_id: string;
+ s3_key: string;
+ reason: string;
+}
+
+export interface BulkDownloadDelivery {
+ /** ZIP link, valid 60 minutes. */
+ presignedUrl: string;
+ packageS3Key: string | null;
+ /** Documents included. */
+ included: number;
+ skipped: BulkDownloadSkipped[];
+}
+
+export type BulkDownloadState = "preparing" | "ready" | "failed";
+
+export interface BulkDownloadStatus {
+ state: BulkDownloadState;
+ delivery: BulkDownloadDelivery | null;
+}
+
+/**
+ * Read the worker's `sub_task.outputs` back into the app's shape. Null for
+ * anything that isn't a finished delivery (in-flight, malformed) — polling must
+ * never throw on an unfinished row.
+ */
+export function parseDelivery(outputs: string | null): BulkDownloadDelivery | null {
+ if (!outputs) return null;
+ try {
+ const raw = JSON.parse(outputs) as Record;
+ // Tolerate link-key naming variants so a completed job surfaces its link.
+ const url = [raw.presigned_url, raw.presignedUrl, raw.download_url, raw.url].find(
+ (v): v is string => typeof v === "string" && v.length > 0,
+ );
+ if (!url) return null;
+ return {
+ presignedUrl: url,
+ packageS3Key:
+ typeof raw.package_s3_key === "string"
+ ? raw.package_s3_key
+ : typeof raw.s3_key === "string"
+ ? raw.s3_key
+ : null,
+ included: typeof raw.included === "number" ? raw.included : 0,
+ skipped: Array.isArray(raw.skipped)
+ ? (raw.skipped as BulkDownloadSkipped[])
+ : [],
+ };
+ } catch {
+ return null;
+ }
+}
+
+/**
+ * Poll cadence: keep checking while the ZIP is being built, stop once it is
+ * ready or failed. Shape matches TanStack v4's refetchInterval callback, which
+ * receives the query data first.
+ */
+export function bulkDownloadRefetchInterval(
+ data: BulkDownloadStatus | undefined,
+): number | false {
+ // Package assembly takes minutes, so a gentle cadence — email is the real
+ // delivery channel; this poll is just an in-session convenience.
+ if (!data) return 8_000;
+ return data.state === "preparing" ? 8_000 : false;
+}
diff --git a/src/lib/bulkDocumentDownload/server.ts b/src/lib/bulkDocumentDownload/server.ts
new file mode 100644
index 00000000..88292f70
--- /dev/null
+++ b/src/lib/bulkDocumentDownload/server.ts
@@ -0,0 +1,171 @@
+import { db } from "@/app/db/db";
+import { tasks } from "@/app/db/schema/tasks/tasks";
+import { subTasks } from "@/app/db/schema/tasks/subtask";
+import { and, desc, eq } from "drizzle-orm";
+import {
+ BULK_DOWNLOAD_TASK_SOURCE,
+ BulkDownloadSelectionInput,
+ BulkDownloadStatus,
+ buildBulkDownloadRecord,
+ buildSelectionConfig,
+ parseDelivery,
+} from "./model";
+
+// The document-service entry point on the backend. It resolves the selection
+// from the task's `inputs`, assembles the ZIP, emails the link (recipient from
+// the JWT), and writes the result to the task's sub_task.outputs.
+const BULK_DOWNLOAD_ENDPOINT = "/v1/documents/bulk-download";
+
+type Dispatch = { ok: true } | { ok: false; status: number; message: string };
+
+function isFailed(status: string | null): boolean {
+ return status ? ["failed", "failure", "error"].includes(status.toLowerCase()) : false;
+}
+
+function defaultMessageForStatus(status: number): string {
+ if (status === 409) return "A download for this selection has already been started.";
+ if (status === 400) return "That selection can’t be downloaded — please adjust it and try again.";
+ return "Couldn’t start the download — please try again.";
+}
+
+/** Pull FastAPI's error detail so a 400 (e.g. over the 500 cap) reaches the user verbatim. */
+async function extractDetail(res: Response): Promise {
+ try {
+ const body = (await res.json()) as Record;
+ const d = body.detail ?? body.message ?? body.error;
+ if (typeof d === "string" && d.trim()) return d;
+ if (Array.isArray(d) && typeof (d[0] as { msg?: unknown })?.msg === "string") {
+ return (d[0] as { msg: string }).msg;
+ }
+ } catch {
+ // not JSON — fall through to the status default
+ }
+ return defaultMessageForStatus(res.status);
+}
+
+async function dispatchBulkDownload(
+ taskId: string,
+ sessionToken: string | undefined,
+): Promise {
+ const url = process.env.FASTAPI_API_URL;
+ const key = process.env.FASTAPI_API_KEY;
+ if (!url || !key) {
+ console.error("FASTAPI_API_URL or FASTAPI_API_KEY not set");
+ return { ok: false, status: 500, message: "Server misconfiguration" };
+ }
+ try {
+ const res = await fetch(`${url}${BULK_DOWNLOAD_ENDPOINT}`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ "x-api-key": key,
+ // The recipient email is resolved from this JWT; no email in the body.
+ Authorization: `Bearer ${sessionToken}`,
+ },
+ body: JSON.stringify({ task_id: taskId }),
+ });
+ if (res.ok) return { ok: true };
+ return { ok: false, status: res.status, message: await extractDetail(res) };
+ } catch (err) {
+ console.error(`Failed to reach FastAPI ${BULK_DOWNLOAD_ENDPOINT}:`, err);
+ return {
+ ok: false,
+ status: 502,
+ message: "Couldn’t reach the document service — please try again.",
+ };
+ }
+}
+
+export type BulkDownloadTriggerOutcome =
+ | { kind: "ok"; taskId: string }
+ | { kind: "invalid_selection"; message: string }
+ | { kind: "backend_error"; status: number; message: string };
+
+/**
+ * Record + dispatch a bulk document download (Modelling-run convention,
+ * ADR-0008): one app-authored task whose `inputs` carries the selection
+ * config, then the document service is handed only the task id — so a large
+ * selection never travels in the HTTP body. A rejected dispatch marks the task
+ * failed so it never lingers as a ghost.
+ */
+export async function triggerBulkDocumentDownload(args: {
+ selection: BulkDownloadSelectionInput;
+ sessionToken: string | undefined;
+}): Promise {
+ const built = buildSelectionConfig(args.selection);
+ if (!built.ok) return { kind: "invalid_selection", message: built.error };
+
+ const record = buildBulkDownloadRecord({
+ portfolioId: String(args.selection.portfolioId),
+ config: built.config,
+ });
+ const now = new Date();
+ const [task] = await db
+ .insert(tasks)
+ .values({ ...record, jobStarted: now })
+ .returning();
+
+ const dispatch = await dispatchBulkDownload(task.id, args.sessionToken);
+ if (!dispatch.ok) {
+ await db.update(tasks).set({ status: "failed" }).where(eq(tasks.id, task.id));
+ return { kind: "backend_error", status: dispatch.status, message: dispatch.message };
+ }
+
+ await db.update(tasks).set({ status: "in progress" }).where(eq(tasks.id, task.id));
+ return { kind: "ok", taskId: task.id };
+}
+
+function isComplete(status: string | null): boolean {
+ return status
+ ? ["completed", "complete", "success", "succeeded", "done"].includes(
+ status.toLowerCase(),
+ )
+ : false;
+}
+
+/**
+ * Status of a triggered download for in-app polling. The worker writes the
+ * presigned URL to the sub_task's `outputs` on success; a selection that yields
+ * zero documents fails the sub_task (no empty ZIP). Terminal state is taken from
+ * completion/failure *status* (task or sub_task) as well as the parsed outputs —
+ * so a finished job never hangs on "preparing" just because the link couldn't be
+ * parsed. Portfolio-scoped so a task id can't be read against another portfolio.
+ */
+export async function getBulkDownloadStatus(
+ portfolioId: string,
+ taskId: string,
+): Promise {
+ const rows = await db
+ .select({
+ taskStatus: tasks.status,
+ taskDone: tasks.jobCompleted,
+ subStatus: subTasks.status,
+ subDone: subTasks.jobCompleted,
+ outputs: subTasks.outputs,
+ })
+ .from(tasks)
+ .leftJoin(subTasks, eq(subTasks.taskId, tasks.id))
+ .where(
+ and(
+ eq(tasks.id, taskId),
+ eq(tasks.taskSource, BULK_DOWNLOAD_TASK_SOURCE),
+ eq(tasks.sourceId, portfolioId),
+ ),
+ )
+ .orderBy(desc(subTasks.updatedAt));
+
+ if (rows.length === 0) return null;
+
+ const delivery = rows.map((r) => parseDelivery(r.outputs)).find(Boolean) ?? null;
+ const failed =
+ isFailed(rows[0].taskStatus) || rows.some((r) => isFailed(r.subStatus));
+ // A job whose sub_task (or task) reports completion is terminal even if the
+ // outputs couldn't be parsed into a link — the link is still emailed.
+ const complete =
+ isComplete(rows[0].taskStatus) ||
+ !!rows[0].taskDone ||
+ rows.some((r) => isComplete(r.subStatus) || !!r.subDone);
+
+ const state = delivery || complete ? "ready" : failed ? "failed" : "preparing";
+ return { state, delivery };
+}
diff --git a/src/lib/bulkUpload/addressMatches.ts b/src/lib/bulkUpload/addressMatches.ts
new file mode 100644
index 00000000..8d3213ab
--- /dev/null
+++ b/src/lib/bulkUpload/addressMatches.ts
@@ -0,0 +1,246 @@
+import { eq } from "drizzle-orm";
+import * as XLSX from "xlsx";
+
+import { db } from "@/app/db/db";
+import { bulkAddressUploads } from "@/app/db/schema/bulk_address_uploads";
+import { bulkUploadUprnCorrections } from "@/app/db/schema/bulk_upload_uprn_corrections";
+import { createRetrofitDataS3Client } from "@/app/utils/s3";
+import { SOURCE_ROW_ID_COLUMN } from "./s3Keys";
+
+// Columns address2uprn writes onto each combiner row (ADR-0057). `status` is the
+// per-row outcome; a withheld/ambiguous/no-match row has an empty `uprn`.
+const UPRN_COL = "address2uprn_uprn";
+const STATUS_COL = "address2uprn_status";
+const LEXISCORE_COL = "address2uprn_lexiscore";
+
+// A combiner row is confidently matched only when address2uprn kept a UPRN AND
+// did not flag it. Everything else — unmatched, ambiguous_duplicate,
+// invalid_postcode, error, or a legacy row with no status but no UPRN — needs
+// the user to resolve it on the Addresses tab before finalise.
+function isConfidentlyMatched(row: Record): boolean {
+ const uprn = (row[UPRN_COL] ?? "").trim();
+ const status = (row[STATUS_COL] ?? "").trim();
+ if (!uprn) return false;
+ return status === "" || status === "matched";
+}
+
+export interface FlaggedAddressRow {
+ sourceRowId: string;
+ address: string;
+ postcode: string;
+ status: string;
+ lexiscore: number | null;
+ // The candidate address2uprn found but did not trust (null when none).
+ suggestedUprn: string | null;
+ // The user's confirmation (from bulk_upload_uprn_corrections), if any.
+ resolvedUprn: string | null;
+ resolvedAddress: string | null;
+ markedNoUprn: boolean;
+ // Resolved = user picked a UPRN OR asserted there is none.
+ resolved: boolean;
+}
+
+function parseS3Uri(uri: string): { bucket: string; key: string } {
+ const url = new URL(uri); // s3://bucket/key...
+ const key = url.pathname.startsWith("/") ? url.pathname.slice(1) : url.pathname;
+ if (!url.hostname || !key) throw new Error(`Malformed S3 URI: ${uri}`);
+ return { bucket: url.hostname, key };
+}
+
+async function readCombinerRows(s3Uri: string): Promise[]> {
+ const { bucket, key } = parseS3Uri(s3Uri);
+ const s3 = createRetrofitDataS3Client();
+ const result = await s3.getObject({ Bucket: bucket, Key: key }).promise();
+ const body = result.Body?.toString("utf-8");
+ if (!body) return [];
+ const wb = XLSX.read(body, { type: "string" });
+ const sheet = wb.Sheets[wb.SheetNames[0]];
+ // Every cell as a string so a numeric UPRN never arrives as a float.
+ return XLSX.utils.sheet_to_json>(sheet, { defval: "", raw: false });
+}
+
+function buildAddress(row: Record): string {
+ return ["Address 1", "Address 2", "Address 3"]
+ .map((c) => (row[c] ?? "").trim())
+ .filter(Boolean)
+ .join(", ");
+}
+
+/**
+ * The combiner rows that need user confirmation, joined with any saved
+ * correction. Reads the combiner CSV from `combinedOutputS3Uri` (ADR-0057).
+ * Returns [] until the combiner has run.
+ */
+export async function getFlaggedAddresses(
+ uploadId: string,
+): Promise {
+ const [row] = await db
+ .select({ combinedOutputS3Uri: bulkAddressUploads.combinedOutputS3Uri })
+ .from(bulkAddressUploads)
+ .where(eq(bulkAddressUploads.id, uploadId));
+ if (!row?.combinedOutputS3Uri) return [];
+
+ const [rows, corrections] = await Promise.all([
+ readCombinerRows(row.combinedOutputS3Uri),
+ db
+ .select()
+ .from(bulkUploadUprnCorrections)
+ .where(eq(bulkUploadUprnCorrections.uploadId, uploadId)),
+ ]);
+
+ const correctionByRow = new Map(corrections.map((c) => [c.sourceRowId, c]));
+
+ return rows
+ .filter((r) => !isConfidentlyMatched(r))
+ .map((r) => {
+ const sourceRowId = (r[SOURCE_ROW_ID_COLUMN] ?? "").trim();
+ const uprn = (r[UPRN_COL] ?? "").trim();
+ const rawScore = (r[LEXISCORE_COL] ?? "").trim();
+ const lexiscore = rawScore === "" ? null : Number(rawScore);
+ const c = correctionByRow.get(sourceRowId);
+ const resolvedUprn = c?.uprn ?? null;
+ const markedNoUprn = c?.markedNoUprn ?? false;
+ return {
+ sourceRowId,
+ address: buildAddress(r),
+ postcode: (r["postcode"] ?? "").trim(),
+ status: (r[STATUS_COL] ?? (uprn ? "matched" : "unmatched")).trim(),
+ lexiscore: lexiscore !== null && Number.isFinite(lexiscore) ? lexiscore : null,
+ suggestedUprn: uprn || null,
+ resolvedUprn,
+ resolvedAddress: c?.address ?? null,
+ markedNoUprn,
+ resolved: resolvedUprn !== null || markedNoUprn,
+ };
+ });
+}
+
+/** Count of flagged rows the user has not yet resolved — gates Finalise. */
+export async function countUnresolvedFlaggedAddresses(uploadId: string): Promise {
+ const flagged = await getFlaggedAddresses(uploadId);
+ return flagged.filter((f) => !f.resolved).length;
+}
+
+const ADDRESS_COL = "address2uprn_address";
+const OVERLAY_STATUS_CONFIRMED = "user_confirmed";
+const OVERLAY_STATUS_NO_UPRN = "user_no_uprn";
+
+/**
+ * Overlay the user's saved corrections onto the combiner CSV and write the
+ * result to a sibling `….confirmed.csv`, returning its S3 URI (ADR-0057). The
+ * finaliser reads this so a confirmed UPRN drives both the identity insert and
+ * property_overrides in one pass. No corrections ⇒ the original URI is returned
+ * unchanged (no rewrite). A `markedNoUprn` row keeps an empty UPRN (accepted
+ * terminal state — the finaliser leaves it as a no-UPRN property).
+ */
+export async function buildConfirmedCombinerUri(
+ uploadId: string,
+ combinedOutputS3Uri: string,
+): Promise {
+ const corrections = await db
+ .select()
+ .from(bulkUploadUprnCorrections)
+ .where(eq(bulkUploadUprnCorrections.uploadId, uploadId));
+ if (corrections.length === 0) return combinedOutputS3Uri;
+ const byRow = new Map(corrections.map((c) => [c.sourceRowId, c]));
+
+ const { bucket, key } = parseS3Uri(combinedOutputS3Uri);
+ const s3 = createRetrofitDataS3Client();
+ const result = await s3.getObject({ Bucket: bucket, Key: key }).promise();
+ const body = result.Body?.toString("utf-8");
+ if (!body) return combinedOutputS3Uri;
+
+ const wb = XLSX.read(body, { type: "string" });
+ const sheet = wb.Sheets[wb.SheetNames[0]];
+ // Array-of-arrays so every column + its order is preserved exactly; we patch
+ // only the address2uprn cells of corrected rows.
+ const aoa = XLSX.utils.sheet_to_json(sheet, {
+ header: 1,
+ defval: "",
+ raw: false,
+ blankrows: false,
+ });
+ const headers = (aoa[0] ?? []).map((h) => String(h));
+ const iRow = headers.indexOf(SOURCE_ROW_ID_COLUMN);
+ const iUprn = headers.indexOf(UPRN_COL);
+ const iStatus = headers.indexOf(STATUS_COL);
+ const iAddr = headers.indexOf(ADDRESS_COL);
+ if (iRow < 0 || iUprn < 0) return combinedOutputS3Uri; // not an address2uprn CSV
+
+ for (let r = 1; r < aoa.length; r++) {
+ const line = aoa[r];
+ const srid = String(line[iRow] ?? "").trim();
+ const c = byRow.get(srid);
+ if (!c) continue;
+ if (c.markedNoUprn) {
+ line[iUprn] = "";
+ if (iStatus >= 0) line[iStatus] = OVERLAY_STATUS_NO_UPRN;
+ } else {
+ line[iUprn] = c.uprn ?? "";
+ if (iStatus >= 0) line[iStatus] = OVERLAY_STATUS_CONFIRMED;
+ if (iAddr >= 0 && c.address) line[iAddr] = c.address;
+ }
+ }
+
+ const csv = XLSX.utils.sheet_to_csv(XLSX.utils.aoa_to_sheet(aoa));
+ const confirmedKey = `${key.replace(/\.csv$/i, "")}.confirmed.csv`;
+ await s3
+ .putObject({ Bucket: bucket, Key: confirmedKey, Body: csv, ContentType: "text/csv" })
+ .promise();
+ return `s3://${bucket}/${confirmedKey}`;
+}
+
+export type UprnCorrectionInput =
+ | {
+ sourceRowId: string;
+ uprn: string;
+ address: string;
+ postcode: string;
+ markedNoUprn?: false;
+ }
+ | { sourceRowId: string; markedNoUprn: true };
+
+/** Upsert one combiner row's confirmation (assign a UPRN, or mark no-UPRN). */
+export async function upsertUprnCorrection(
+ uploadId: string,
+ input: UprnCorrectionInput,
+ userId?: string,
+): Promise {
+ const values = input.markedNoUprn
+ ? {
+ uploadId,
+ sourceRowId: input.sourceRowId,
+ uprn: null,
+ address: null,
+ postcode: null,
+ markedNoUprn: true as const,
+ userId: userId ?? null,
+ }
+ : {
+ uploadId,
+ sourceRowId: input.sourceRowId,
+ uprn: input.uprn,
+ address: input.address,
+ postcode: input.postcode,
+ markedNoUprn: false as const,
+ userId: userId ?? null,
+ };
+
+ await db
+ .insert(bulkUploadUprnCorrections)
+ .values(values)
+ .onConflictDoUpdate({
+ target: [
+ bulkUploadUprnCorrections.uploadId,
+ bulkUploadUprnCorrections.sourceRowId,
+ ],
+ set: {
+ uprn: values.uprn,
+ address: values.address,
+ postcode: values.postcode,
+ markedNoUprn: values.markedNoUprn,
+ userId: values.userId,
+ updatedAt: new Date(),
+ },
+ });
+}
diff --git a/src/lib/bulkUpload/client.ts b/src/lib/bulkUpload/client.ts
index 3f3a34e9..939d0f01 100644
--- a/src/lib/bulkUpload/client.ts
+++ b/src/lib/bulkUpload/client.ts
@@ -150,6 +150,74 @@ export function useSampleClassifications(
});
}
+// One combiner row that address2uprn could not confidently match (ADR-0057),
+// plus any saved correction. Mirrors the server FlaggedAddressRow.
+export interface FlaggedAddress {
+ sourceRowId: string;
+ address: string;
+ postcode: string;
+ status: string;
+ lexiscore: number | null;
+ suggestedUprn: string | null;
+ resolvedUprn: string | null;
+ resolvedAddress: string | null;
+ markedNoUprn: boolean;
+ resolved: boolean;
+}
+
+export interface AddressMatchesView {
+ flagged: FlaggedAddress[];
+ unresolved: number;
+}
+
+export function useAddressMatches(
+ portfolioId: string,
+ uploadId: string,
+ enabled: boolean,
+) {
+ return useQuery({
+ queryKey: [...bulkUploadKeys.progress(uploadId), "address-matches"],
+ enabled,
+ queryFn: async () => {
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/bulk-uploads/${uploadId}/address-matches`,
+ );
+ if (!res.ok) throw await parseError(res, "Failed to load address matches.");
+ const body = await res.json();
+ return {
+ flagged: (body.flagged ?? []) as FlaggedAddress[],
+ unresolved: Number(body.unresolved ?? 0),
+ };
+ },
+ });
+}
+
+export type SaveCorrectionInput =
+ | { sourceRowId: string; uprn: string; address: string; postcode: string }
+ | { sourceRowId: string; markedNoUprn: true };
+
+export function useSaveUprnCorrection(portfolioId: string, uploadId: string) {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async (input) => {
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/bulk-uploads/${uploadId}/address-corrections`,
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(input),
+ },
+ );
+ if (!res.ok) throw await parseError(res, "Failed to save address.");
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({
+ queryKey: [...bulkUploadKeys.progress(uploadId), "address-matches"],
+ });
+ },
+ });
+}
+
export function useConfirmMultiEntryOrdering(portfolioId: string, uploadId: string) {
const queryClient = useQueryClient();
return useMutation }>({
diff --git a/src/lib/bulkUpload/server.ts b/src/lib/bulkUpload/server.ts
index b442e0c3..7518fae0 100644
--- a/src/lib/bulkUpload/server.ts
+++ b/src/lib/bulkUpload/server.ts
@@ -16,6 +16,10 @@ import { retrofitDataS3Bucket } from "@/app/utils/s3";
import { SUBTASK_SERVICE } from "./types";
import type { MultiEntrySummary } from "./multiEntry";
import { isPermutation } from "./multiEntry";
+import {
+ buildConfirmedCombinerUri,
+ countUnresolvedFlaggedAddresses,
+} from "./addressMatches";
const REMAP_ALLOWED: ReadonlySet = new Set([
"ready_for_processing",
@@ -603,6 +607,7 @@ export type DispatchFinaliserOutcome =
| { kind: "not_yet_combined" }
| { kind: "wrong_state"; current: string }
| { kind: "missing_task" }
+ | { kind: "unresolved_addresses"; count: number }
| { kind: "trigger_failed"; status: number; message: string };
// Dispatch the async bulk_upload_finaliser (ADR-0005). Replaces the old
@@ -631,6 +636,14 @@ export async function dispatchFinaliser(args: {
const upload = guarded.upload;
if (!upload.taskId) return { kind: "missing_task" };
+ // ADR-0057: every combiner row address2uprn could not confidently match must
+ // be resolved on the Addresses tab (a chosen UPRN or an explicit no-UPRN)
+ // before finalise — otherwise a withheld row would land as an unintended
+ // no-UPRN property. Gate before the CAS claim so a blocked upload stays in
+ // awaiting_review.
+ const unresolved = await countUnresolvedFlaggedAddresses(args.uploadId);
+ if (unresolved > 0) return { kind: "unresolved_addresses", count: unresolved };
+
// CAS: atomically claim the dispatch. Only the request that flips
// awaiting_review → finalising proceeds; a concurrent one updates 0 rows.
const claimed = await db
@@ -674,10 +687,18 @@ export async function dispatchFinaliser(args: {
? `s3://${retrofitDataS3Bucket()}/${classifierCsvKey(upload.portfolioId, args.uploadId)}`
: null;
+ // Overlay the user's confirmed UPRNs onto the combiner CSV and point the
+ // finaliser at the corrected copy (ADR-0057). No corrections ⇒ the original
+ // URI is returned unchanged.
+ const confirmedS3Uri = await buildConfirmedCombinerUri(
+ args.uploadId,
+ upload.combinedOutputS3Uri!,
+ );
+
const payload = {
task_id: upload.taskId,
sub_task_id: subTask.id,
- s3_uri: upload.combinedOutputS3Uri,
+ s3_uri: confirmedS3Uri,
portfolio_id: Number(upload.portfolioId),
bulk_upload_id: args.uploadId,
classifier_s3_uri: classifierS3Uri,
diff --git a/src/lib/modellingRuns/model.test.ts b/src/lib/modellingRuns/model.test.ts
index 5bd39f8c..b37789bc 100644
--- a/src/lib/modellingRuns/model.test.ts
+++ b/src/lib/modellingRuns/model.test.ts
@@ -46,6 +46,24 @@ describe("normaliseRunFilters", () => {
});
});
+describe("normaliseRunFilters — tags", () => {
+ it("normalises tag ids to a deduped, ascending number list", () => {
+ expect(normaliseRunFilters({ tagIds: [3, "1", 3, 2] })).toEqual({
+ ok: true,
+ filters: { tagIds: [1, 2, 3] },
+ });
+ });
+
+ it("rejects a non-numeric or non-positive tag id", () => {
+ expect(normaliseRunFilters({ tagIds: [1, "x"] }).ok).toBe(false);
+ expect(normaliseRunFilters({ tagIds: [0] }).ok).toBe(false);
+ });
+
+ it("treats an absent/empty tag selection as unconstrained (no key)", () => {
+ expect(normaliseRunFilters({ tagIds: [] })).toEqual({ ok: true, filters: {} });
+ });
+});
+
describe("buildRunRecord", () => {
it("produces the app-authored task row carrying the run config as its inputs (ADR-0008)", () => {
const record = buildRunRecord({
@@ -76,6 +94,18 @@ describe("buildRunRecord", () => {
filters: { postcodes: ["B93 8SU"], property_types: ["House"] },
});
});
+
+ it("carries tag ids into the task inputs, the dispatch payload, and back (ADR-0013)", () => {
+ const { task, dispatchPayload } = buildRunRecord({
+ portfolioId: "5",
+ scenarioIds: ["2"],
+ filters: { tagIds: [7, 3] },
+ previewedPropertyCount: 10,
+ triggeredBy: "u@x.io",
+ });
+ expect(dispatchPayload.filters).toEqual({ tag_ids: [7, 3] });
+ expect(parseRunConfig(task.inputs)?.filters.tagIds).toEqual([7, 3]);
+ });
});
describe("parseRunConfig", () => {
@@ -113,6 +143,11 @@ describe("selectionSummary", () => {
}),
).toBe("Postcodes: B93 8SU, M20 4TF · Type: House · Built form: Detached, Unknown");
});
+
+ it("summarises a tag selection as a count (names aren't in the pure filters)", () => {
+ expect(selectionSummary({ tagIds: [7, 3] })).toBe("Tags: 2");
+ expect(selectionSummary({ tagIds: [7] })).toBe("Tags: 1");
+ });
});
describe("deriveRunStatus", () => {
diff --git a/src/lib/modellingRuns/model.ts b/src/lib/modellingRuns/model.ts
index 179af4a7..103858f9 100644
--- a/src/lib/modellingRuns/model.ts
+++ b/src/lib/modellingRuns/model.ts
@@ -21,6 +21,8 @@ export interface RunFilters {
postcodes?: string[];
propertyTypes?: string[];
builtForms?: string[];
+ /** Portfolio Tag ids (any-of); resolved against property_tag (ADR-0013). */
+ tagIds?: number[];
}
export type NormaliseFiltersResult =
@@ -34,6 +36,7 @@ export function normaliseRunFilters(input: {
postcodes?: string[];
propertyTypes?: string[];
builtForms?: string[];
+ tagIds?: (number | string)[];
}): NormaliseFiltersResult {
const filters: RunFilters = {};
if (input.postcodes?.length) {
@@ -65,6 +68,20 @@ export function normaliseRunFilters(input: {
}
filters[key] = [...new Set(values)];
}
+ // Tags are dynamic (portfolio-specific), so there's no vocabulary to check
+ // against — just coerce to positive integer ids, dedupe and sort. Ids that
+ // don't belong to the portfolio simply match nothing at resolution time.
+ if (input.tagIds?.length) {
+ const ids = new Set();
+ for (const raw of input.tagIds) {
+ const n = Number(raw);
+ if (!Number.isInteger(n) || n <= 0) {
+ return { ok: false, error: `Invalid tag '${raw}'` };
+ }
+ ids.add(n);
+ }
+ filters.tagIds = [...ids].sort((a, b) => a - b);
+ }
return { ok: true, filters };
}
@@ -91,6 +108,7 @@ export function parseRunConfig(inputs: string | null): RunConfigView | null {
if (raw.filters?.postcodes?.length) filters.postcodes = raw.filters.postcodes;
if (raw.filters?.property_types?.length) filters.propertyTypes = raw.filters.property_types;
if (raw.filters?.built_forms?.length) filters.builtForms = raw.filters.built_forms;
+ if (raw.filters?.tag_ids?.length) filters.tagIds = raw.filters.tag_ids;
return {
scenarioIds: raw.scenario_ids.map(String),
filters,
@@ -167,6 +185,9 @@ export function selectionSummary(filters: RunFilters): string {
if (filters.postcodes?.length) bits.push(`Postcodes: ${filters.postcodes.join(", ")}`);
if (filters.propertyTypes?.length) bits.push(`Type: ${filters.propertyTypes.join(", ")}`);
if (filters.builtForms?.length) bits.push(`Built form: ${filters.builtForms.join(", ")}`);
+ // Tag names aren't carried in the pure filters (only ids), so summarise as a
+ // count; the run-history UI resolves names separately when it needs them.
+ if (filters.tagIds?.length) bits.push(`Tags: ${filters.tagIds.length}`);
return bits.length ? bits.join(" · ") : "All properties";
}
@@ -186,6 +207,7 @@ export interface RunConfigInputs {
postcodes?: string[];
property_types?: string[];
built_forms?: string[];
+ tag_ids?: number[];
};
previewed_property_count: number;
triggered_by: string;
@@ -212,6 +234,7 @@ export function buildRunRecord(req: RunRequest): {
if (req.filters.postcodes) filters.postcodes = req.filters.postcodes;
if (req.filters.propertyTypes) filters.property_types = req.filters.propertyTypes;
if (req.filters.builtForms) filters.built_forms = req.filters.builtForms;
+ if (req.filters.tagIds) filters.tag_ids = req.filters.tagIds;
const configInputs: RunConfigInputs = {
portfolio_id: Number(req.portfolioId),
scenario_ids: req.scenarioIds.map(Number),
diff --git a/src/lib/modellingRuns/server.ts b/src/lib/modellingRuns/server.ts
index 63f03c31..f6c77b01 100644
--- a/src/lib/modellingRuns/server.ts
+++ b/src/lib/modellingRuns/server.ts
@@ -11,7 +11,12 @@ import {
parseRunConfig,
selectionSummary,
} from "./model";
-import { builtFormTypeSql, propertyTypeSql } from "@/lib/services/epcSources";
+import {
+ builtFormOverrideJoin,
+ propertyTypeOverrideJoin,
+ resolvedBuiltFormSql,
+ resolvedPropertyTypeSql,
+} from "@/lib/services/epcSources";
// Distributor entry point on the Model backend. It fans the run out to
// workers, attaching execution sub-tasks to the task_id we pass (ADR-0008).
@@ -141,20 +146,27 @@ export async function previewModellingRun(args: {
if (args.filters.builtForms) {
conditions.push(sql`resolved.bform IN (${inList(args.filters.builtForms)})`);
}
+ if (args.filters.tagIds) {
+ // Tags resolve by direct membership (any-of), not the override→EPC rule —
+ // ADR-0013. The distributor mirrors this join against the shared DB.
+ conditions.push(
+ sql`resolved.id IN (SELECT pt.property_id FROM property_tag pt WHERE pt.tag_id IN (${inList(args.filters.tagIds)}))`,
+ );
+ }
const result = await db.execute<{
matched: number;
per_scenario: { scenario_id: string; n: number }[] | null;
}>(sql`
WITH resolved AS (
+ -- Resolution rule shared with the portfolio list via epcSources fragments
+ -- so the preview and the list can never drift (ADR-0008, ADR-0012).
SELECT p.id, p.postcode,
- COALESCE(pot.override_value, ${propertyTypeSql}, 'Unknown') AS ptype,
- COALESCE(pobf.override_value, ${builtFormTypeSql}, 'Unknown') AS bform
+ ${resolvedPropertyTypeSql} AS ptype,
+ ${resolvedBuiltFormSql} AS bform
FROM property p
- LEFT JOIN property_overrides pot ON pot.property_id = p.id
- AND pot.override_component = 'property_type' AND pot.building_part = 0
- LEFT JOIN property_overrides pobf ON pobf.property_id = p.id
- AND pobf.override_component = 'built_form_type' AND pobf.building_part = 0
+ ${propertyTypeOverrideJoin}
+ ${builtFormOverrideJoin}
LEFT JOIN epc_property epl ON epl.property_id = p.id AND epl.source = 'lodged'
LEFT JOIN epc_property epp ON epp.property_id = p.id AND epp.source = 'predicted'
WHERE p.portfolio_id = ${pid} AND p.marked_for_deletion = false
diff --git a/src/lib/postcodeSearch/model.test.ts b/src/lib/postcodeSearch/model.test.ts
index 3c1449eb..e18b6d9e 100644
--- a/src/lib/postcodeSearch/model.test.ts
+++ b/src/lib/postcodeSearch/model.test.ts
@@ -20,6 +20,13 @@ describe("classifyOsCode", () => {
expect(classifyOsCode("RD07")).toEqual({ selectable: true, propertyType: "House", builtForm: null });
});
+ it("maps the RH (HMO) family to House, like RD07", () => {
+ // e.g. UPRN 100031252876, 7 Leyton Avenue — RH03 must not read as non-residential.
+ expect(classifyOsCode("RH01")).toEqual({ selectable: true, propertyType: "House", builtForm: null });
+ expect(classifyOsCode("RH02")).toEqual({ selectable: true, propertyType: "House", builtForm: null });
+ expect(classifyOsCode("RH03")).toEqual({ selectable: true, propertyType: "House", builtForm: null });
+ });
+
it("keeps other residential codes selectable but writes no facts — never Unknown", () => {
for (const code of ["RD", "RD01", "RD08"]) {
expect(classifyOsCode(code)).toEqual({ selectable: true, propertyType: null, builtForm: null });
@@ -63,6 +70,21 @@ describe("toAddressCandidates", () => {
expect(out[1]).toMatchObject({ uprn: "101", selectable: false });
});
+ it("classifies an RH03 HMO as a selectable House, not Non-residential", () => {
+ // Regression: 7 Leyton Avenue (UPRN 100031252876) came back RH03 ("HMO Not
+ // Further Divided") on a street of RD02/RD03 houses and rendered as
+ // "Non-residential", so it couldn't be added.
+ const hmo = [
+ { DPA: { UPRN: "100031252876", ADDRESS: "7, LEYTON AVENUE, SUTTON-IN-ASHFIELD, NG17 3BD",
+ POSTCODE: "NG17 3BD", CLASSIFICATION_CODE: "RH03", LAT: 53.1352313, LNG: -1.2522665 } },
+ ];
+ const out = toAddressCandidates(hmo as never, "NG17 3BD");
+ expect(out[0]).toMatchObject({
+ uprn: "100031252876", address: "7, Leyton Avenue, Sutton-In-Ashfield",
+ classificationCode: "RH03", selectable: true, propertyType: "House", builtForm: null,
+ });
+ });
+
it("orders addresses numerically, so Flat 2 comes before Flat 10", () => {
const flats = [
{ DPA: { UPRN: "1", ADDRESS: "FLAT 10, BIRCH COURT, M20 4TF", CLASSIFICATION_CODE: "RD06" } },
@@ -102,6 +124,18 @@ describe("buildWritePlan", () => {
{ component: "built_form_type", value: "Detached", originalDescription: "RD02", buildingPart: 0 },
]);
});
+ it("writes a House property_type override for an RH03 HMO, keyed to the OS code", () => {
+ const plan = buildWritePlan(
+ { uprn: "100031252876", address: "7, Leyton Avenue, Sutton-In-Ashfield", postcode: "NG17 3BD",
+ classificationCode: "RH03", lat: 53.1352313, lng: -1.2522665, selectable: true,
+ propertyType: "House", builtForm: null },
+ geo,
+ );
+ // HMO built form is unknowable, so only the property_type fact is written.
+ expect(plan.overrides).toEqual([
+ { component: "property_type", value: "House", originalDescription: "RH03", buildingPart: 0 },
+ ]);
+ });
it("writes no overrides when the code maps nothing — never Unknown", () => {
const plan = buildWritePlan(
{ uprn: "200", address: "Birch Court", postcode: "M20 4UD", classificationCode: "RD",
diff --git a/src/lib/postcodeSearch/model.ts b/src/lib/postcodeSearch/model.ts
index 289cdb2d..fd1c226e 100644
--- a/src/lib/postcodeSearch/model.ts
+++ b/src/lib/postcodeSearch/model.ts
@@ -28,7 +28,11 @@ const OS_CODE_FACTS: Record {
+ const body = await res.json().catch(() => ({}));
+ return new Error(body?.error ?? fallback);
+}
+
+// One address candidate returned by the portfolio postcode search, plus the
+// server-computed flag for candidates already assigned in this portfolio.
+export interface SearchCandidate {
+ uprn: string;
+ address: string;
+ postcode: string;
+ classificationCode: string | null;
+ selectable: boolean; // residential (per OS classification)
+ propertyType: string | null;
+ builtForm: string | null;
+ alreadyInPortfolio: boolean;
+}
+
+export interface AddressSearchResult {
+ postcode: string;
+ source: "cache" | "live";
+ candidates: SearchCandidate[];
+}
+
+// Run the postcode → address-candidate search. Reuses the add-properties
+// endpoint, which read-through caches OS Places results per postcode in the
+// postcode_search table (30-day TTL) — so repeat searches of the same postcode
+// hit our DB, not the OS API. Throws with the server's { error } on failure.
+export async function searchAddresses(
+ portfolioId: string,
+ postcode: string,
+): Promise {
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/properties/search?postcode=${encodeURIComponent(postcode)}`,
+ );
+ if (!res.ok) throw await parseError(res, "Address search failed.");
+ return res.json();
+}
+
+export interface AssignUprnInput {
+ uprn: string;
+ address: string;
+ postcode: string;
+ userInputtedAddress?: string;
+ userInputtedPostcode?: string;
+}
+
+// Assign a chosen candidate's UPRN + address to a property.
+export function useAssignUprn(portfolioId: string, propertyId: string) {
+ return useMutation<{ ok: true }, Error, AssignUprnInput>({
+ mutationFn: async (input) => {
+ const res = await fetch(
+ `/api/portfolio/${portfolioId}/properties/${propertyId}`,
+ {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(input),
+ },
+ );
+ if (!res.ok) throw await parseError(res, "Failed to assign UPRN.");
+ return res.json();
+ },
+ });
+}
diff --git a/src/lib/properties/unmatched.ts b/src/lib/properties/unmatched.ts
new file mode 100644
index 00000000..9f8e6334
--- /dev/null
+++ b/src/lib/properties/unmatched.ts
@@ -0,0 +1,47 @@
+import { db } from "@/app/db/db";
+import { property } from "@/app/db/schema/property";
+import { and, asc, eq, isNull } from "drizzle-orm";
+
+export interface UnmatchedProperty {
+ id: string;
+ address: string | null;
+ postcode: string | null;
+}
+
+// Properties in a portfolio that have no UPRN — i.e. were never matched to an
+// Ordnance Survey address record. We surface these separately from the main
+// property table so the customer can correct the address/postcode and re-run
+// the address→UPRN search (the "advanced ARA search", wired up in a follow-up).
+// `markedForDeletion` rows are excluded so soft-deleted properties don't show.
+export async function getUnmatchedProperties(
+ portfolioId: string,
+): Promise {
+ if (!/^\d+$/.test(portfolioId)) return [];
+ const pid = BigInt(portfolioId);
+
+ const rows = await db
+ .select({
+ id: property.id,
+ address: property.address,
+ postcode: property.postcode,
+ userInputtedAddress: property.userInputtedAddress,
+ userInputtedPostcode: property.userInputtedPostcode,
+ })
+ .from(property)
+ .where(
+ and(
+ eq(property.portfolioId, pid),
+ isNull(property.uprn),
+ eq(property.markedForDeletion, false),
+ ),
+ )
+ .orderBy(asc(property.address));
+
+ // Prefer the canonical address; fall back to whatever the user typed on
+ // import so the row is still identifiable while it awaits a match.
+ return rows.map((r) => ({
+ id: String(r.id),
+ address: r.address ?? r.userInputtedAddress ?? null,
+ postcode: r.postcode ?? r.userInputtedPostcode ?? null,
+ }));
+}
diff --git a/src/lib/scenarios/model.test.ts b/src/lib/scenarios/model.test.ts
index c901b236..c84e0207 100644
--- a/src/lib/scenarios/model.test.ts
+++ b/src/lib/scenarios/model.test.ts
@@ -197,6 +197,18 @@ describe("validateScenarioConfig", () => {
expect(result.ok).toBe(false);
if (!result.ok) expect(result.errors.exclusions).toBeTruthy();
});
+
+ it("carries fabric first through when the scenario is fabric-first", () => {
+ const result = validateScenarioConfig({ ...validBase, exclusions: [], fabricFirst: true });
+ expect(result.ok).toBe(true);
+ if (result.ok) expect(result.value.fabricFirst).toBe(true);
+ });
+
+ it("defaults fabric first to false when the flag is absent", () => {
+ const result = validateScenarioConfig({ ...validBase, exclusions: [] });
+ expect(result.ok).toBe(true);
+ if (result.ok) expect(result.value.fabricFirst).toBe(false);
+ });
});
describe("scenarioToInsertRow", () => {
@@ -241,14 +253,30 @@ describe("scenarioToInsertRow", () => {
expect(row.budget).toBeNull();
expect(row.exclusions).toBeNull();
});
+
+ it("persists the fabric-first flag, defaulting to false", () => {
+ const off = validateScenarioConfig({
+ name: "Reach EPC C", housingType: "Social", goal: "Increasing EPC",
+ goalValue: "C", budgetPerProperty: null, exclusions: [],
+ });
+ const on = validateScenarioConfig({
+ name: "Reach EPC C — fabric first", housingType: "Social", goal: "Increasing EPC",
+ goalValue: "C", budgetPerProperty: null, exclusions: [], fabricFirst: true,
+ });
+ expect(off.ok && on.ok).toBe(true);
+ if (!off.ok || !on.ok) return;
+ expect(scenarioToInsertRow(off.value, 1n).fabricFirst).toBe(false);
+ expect(scenarioToInsertRow(on.value, 1n).fabricFirst).toBe(true);
+ });
});
describe("findExactDuplicate", () => {
const existing = [
{ id: 1n, name: "Reach EPC C", housingType: "Social", goal: "Increasing EPC",
- goalValue: "C", budget: null, exclusions: "{external_wall_insulation,solid_floor_insulation}" },
+ goalValue: "C", budget: null, exclusions: "{external_wall_insulation,solid_floor_insulation}",
+ fabricFirst: false },
{ id: 2n, name: "Max CO₂", housingType: "Social", goal: "Reducing CO2 emissions",
- goalValue: null, budget: 6000, exclusions: null },
+ goalValue: null, budget: 6000, exclusions: null, fabricFirst: false },
];
const config = {
name: "A totally different name",
@@ -271,6 +299,18 @@ describe("findExactDuplicate", () => {
findExactDuplicate({ ...config, exclusions: ["solid_floor_insulation"] }, existing),
).toBeNull();
});
+
+ it("treats fabric first as part of the configuration identity", () => {
+ // id 1 is not fabric-first; the same config asked fabric-first is a distinct question.
+ expect(findExactDuplicate({ ...config, fabricFirst: true }, existing)).toBeNull();
+ // ...and matches once both sides agree it is fabric-first.
+ const fabricFirstExisting = existing.map((s) =>
+ s.id === 1n ? { ...s, fabricFirst: true } : s,
+ );
+ expect(
+ findExactDuplicate({ ...config, fabricFirst: true }, fabricFirstExisting)?.id,
+ ).toBe(1n);
+ });
});
describe("DISRUPTIVE_MEASURES", () => {
diff --git a/src/lib/scenarios/model.ts b/src/lib/scenarios/model.ts
index fe2e3820..56639302 100644
--- a/src/lib/scenarios/model.ts
+++ b/src/lib/scenarios/model.ts
@@ -75,6 +75,8 @@ export interface ScenarioConfigInput {
goalValue: string | null;
budgetPerProperty: number | null;
exclusions: string[];
+ /** Fabric-before-heating ordering constraint (CONTEXT.md). Off by default. */
+ fabricFirst?: boolean;
}
export type ValidationResult =
@@ -128,7 +130,10 @@ export function validateScenarioConfig(
}
if (Object.keys(errors).length > 0) return { ok: false, errors };
- return { ok: true, value: { ...input, name, goalValue, exclusions } };
+ return {
+ ok: true,
+ value: { ...input, name, goalValue, exclusions, fabricFirst: input.fabricFirst ?? false },
+ };
}
/**
@@ -162,6 +167,7 @@ export function scenarioToInsertRow(
exclusions: serializeExclusions(value.exclusions),
multiPlan: true,
isDefault: false,
+ fabricFirst: value.fabricFirst ?? false,
};
}
@@ -233,17 +239,20 @@ export interface ExistingScenarioConfig {
goalValue: string | null;
budget: number | null;
exclusions: string | null;
+ fabricFirst: boolean;
}
/**
- * Exact-configuration duplicate: same goal, goal value, housing type, budget
- * and exclusion set. The name is a label and is deliberately ignored —
- * an identically-configured scenario would model to identical plans.
+ * Exact-configuration duplicate: same goal, goal value, housing type, budget,
+ * exclusion set and fabric-first flag. The name is a label and is deliberately
+ * ignored — an identically-configured scenario would model to identical plans,
+ * so any facet that changes the modelled outcome (fabric-first among them)
+ * makes it a distinct question.
*/
export function findExactDuplicate(
config: Pick<
ScenarioConfigInput,
- "housingType" | "goal" | "goalValue" | "budgetPerProperty" | "exclusions"
+ "housingType" | "goal" | "goalValue" | "budgetPerProperty" | "exclusions" | "fabricFirst"
>,
existing: ExistingScenarioConfig[],
): ExistingScenarioConfig | null {
@@ -255,6 +264,7 @@ export function findExactDuplicate(
(s.goalValue ?? null) === (config.goalValue ?? null) &&
s.housingType === config.housingType &&
(s.budget ?? null) === (config.budgetPerProperty ?? null) &&
+ (s.fabricFirst ?? false) === (config.fabricFirst ?? false) &&
parseExclusions(s.exclusions).sort().join(",") === wanted,
) ?? null
);
diff --git a/src/lib/scenarios/queries.ts b/src/lib/scenarios/queries.ts
index 74b0de9f..f6e2a12c 100644
--- a/src/lib/scenarios/queries.ts
+++ b/src/lib/scenarios/queries.ts
@@ -24,6 +24,7 @@ export interface ScenarioListItem {
goalValue: string | null;
budget: number | null;
exclusions: string[];
+ fabricFirst: boolean;
createdAt: Date;
plansCount: number;
status: ScenarioStatus;
@@ -56,6 +57,7 @@ export async function listScenariosWithStatus(
goalValue: s.goalValue,
budget: s.budget,
exclusions: parseExclusions(s.exclusions),
+ fabricFirst: s.fabricFirst,
createdAt: s.createdAt,
plansCount,
status: deriveScenarioStatus(plansCount),
@@ -82,6 +84,7 @@ export async function getScenarioWithPlansCount(
goalValue: row.goalValue,
budget: row.budget,
exclusions: parseExclusions(row.exclusions),
+ fabricFirst: row.fabricFirst,
createdAt: row.createdAt,
plansCount,
status: deriveScenarioStatus(plansCount),
diff --git a/src/lib/services/descriptorResolution.test.ts b/src/lib/services/descriptorResolution.test.ts
new file mode 100644
index 00000000..1c487586
--- /dev/null
+++ b/src/lib/services/descriptorResolution.test.ts
@@ -0,0 +1,521 @@
+import { describe, expect, it } from "vitest";
+import {
+ resolveBuiltForm,
+ resolveConstructionAge,
+ resolveMainFuel,
+ resolveOverrideDescriptor,
+ resolvePropertyType,
+} from "./descriptorResolution";
+import {
+ MAINFUEL_OPTIONS,
+ RDSAP_MAIN_FUEL_CODE_LABELS,
+ EPR_MAIN_FUEL_STRING_LABELS,
+ WALL_TYPE_OPTIONS,
+ ROOF_TYPE_OPTIONS,
+ HEATING_SYSTEM_OPTIONS,
+ DESCRIPTOR_FILTER_CONFIG,
+ classifyDescriptor,
+} from "@/app/utils/propertyFilters";
+import {
+ MainFuelValues,
+ WallTypeValues,
+ RoofTypeValues,
+ MainHeatingSystemValues,
+} from "@/app/db/schema/landlord_overrides";
+
+describe("resolvePropertyType", () => {
+ it("prefers a landlord override over the EPC-derived value", () => {
+ expect(
+ resolvePropertyType({
+ override: "Maisonette",
+ isNewApproach: true,
+ lodgedPropertyType: "2", // EPC code for Flat
+ lodgedDwellingType: null,
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("Maisonette");
+ });
+
+ it("maps an RdSAP property-type code to its label when there is no override", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: true,
+ lodgedPropertyType: "0", // RdSAP code for House
+ lodgedDwellingType: null,
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("House");
+ });
+
+ it("falls back to the predicted EPC when there is no lodged value", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: true,
+ lodgedPropertyType: null,
+ lodgedDwellingType: null,
+ predictedPropertyType: "2", // RdSAP code for Flat
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("Flat");
+ });
+
+ it("prefers the lodged EPC over the predicted EPC when both exist", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: true,
+ lodgedPropertyType: "0", // House
+ lodgedDwellingType: null,
+ predictedPropertyType: "2", // Flat
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("House");
+ });
+
+ it("falls back to dwelling_type when the lodged property_type is absent", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: true,
+ lodgedPropertyType: null,
+ lodgedDwellingType: "Flat",
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("Flat");
+ });
+
+ it("reads the legacy property-row value for a legacy property", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: false,
+ lodgedPropertyType: "0", // must be ignored for legacy
+ lodgedDwellingType: null,
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: "Bungalow",
+ }),
+ ).toBe("Bungalow");
+ });
+
+ it("never reads the EPC graph nor the legacy row across the cutoff (new-approach ignores the legacy row)", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: true,
+ lodgedPropertyType: null,
+ lodgedDwellingType: null,
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: "Bungalow", // legacy row must NOT surface for a new-approach property
+ }),
+ ).toBe("Unknown");
+ });
+
+ // Spec locks for decisions taken in ADR-0012 — an override always wins (even an
+ // explicit "Unknown"), and an unrecognised RdSAP code is passed through as-is.
+ it("lets an explicit 'Unknown' override win over a known EPC value", () => {
+ expect(
+ resolvePropertyType({
+ override: "Unknown",
+ isNewApproach: true,
+ lodgedPropertyType: "0", // EPC knows "House" — the override still wins
+ lodgedDwellingType: null,
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("Unknown");
+ });
+
+ it("passes an unrecognised RdSAP code through unchanged", () => {
+ expect(
+ resolvePropertyType({
+ override: null,
+ isNewApproach: true,
+ lodgedPropertyType: "9", // not in PROPERTY_TYPE_LABELS
+ lodgedDwellingType: null,
+ predictedPropertyType: null,
+ predictedDwellingType: null,
+ legacyPropertyType: null,
+ }),
+ ).toBe("9");
+ });
+});
+
+describe("resolveBuiltForm", () => {
+ it("prefers a landlord override over the EPC-derived value", () => {
+ expect(
+ resolveBuiltForm({
+ override: "Detached",
+ isNewApproach: true,
+ lodgedBuiltForm: "4", // EPC code for Mid-Terrace
+ predictedBuiltForm: null,
+ legacyBuiltForm: null,
+ }),
+ ).toBe("Detached");
+ });
+
+ it("maps an RdSAP built-form code to its label when there is no override", () => {
+ expect(
+ resolveBuiltForm({
+ override: null,
+ isNewApproach: true,
+ lodgedBuiltForm: "2", // RdSAP code for Semi-Detached
+ predictedBuiltForm: null,
+ legacyBuiltForm: null,
+ }),
+ ).toBe("Semi-Detached");
+ });
+
+ it("falls back to the predicted EPC when there is no lodged value", () => {
+ expect(
+ resolveBuiltForm({
+ override: null,
+ isNewApproach: true,
+ lodgedBuiltForm: null,
+ predictedBuiltForm: "1", // Detached
+ legacyBuiltForm: null,
+ }),
+ ).toBe("Detached");
+ });
+
+ it("reads the legacy property-row value for a legacy property", () => {
+ expect(
+ resolveBuiltForm({
+ override: null,
+ isNewApproach: false,
+ lodgedBuiltForm: "1", // must be ignored for legacy
+ predictedBuiltForm: null,
+ legacyBuiltForm: "End-Terrace",
+ }),
+ ).toBe("End-Terrace");
+ });
+
+ it("resolves to 'Unknown' when nothing is available (never null)", () => {
+ expect(
+ resolveBuiltForm({
+ override: null,
+ isNewApproach: true,
+ lodgedBuiltForm: null,
+ predictedBuiltForm: null,
+ legacyBuiltForm: "Detached", // legacy row must NOT surface for new-approach
+ }),
+ ).toBe("Unknown");
+ });
+});
+
+describe("resolveConstructionAge", () => {
+ it("maps a landlord override band letter to its band label", () => {
+ expect(
+ resolveConstructionAge({
+ override: "B",
+ isNewApproach: true,
+ lodgedAgeBand: "F", // EPC says a different band — override still wins
+ predictedAgeBand: null,
+ legacyYearBuilt: null,
+ }),
+ ).toBe("1900–1929");
+ });
+
+ it("maps the lodged EPC band letter to its label when there is no override", () => {
+ expect(
+ resolveConstructionAge({
+ override: null,
+ isNewApproach: true,
+ lodgedAgeBand: "C",
+ predictedAgeBand: null,
+ legacyYearBuilt: null,
+ }),
+ ).toBe("1930–1949");
+ });
+
+ it("falls back to the predicted EPC band when there is no lodged band", () => {
+ expect(
+ resolveConstructionAge({
+ override: null,
+ isNewApproach: true,
+ lodgedAgeBand: null,
+ predictedAgeBand: "M",
+ legacyYearBuilt: null,
+ }),
+ ).toBe("2023 onwards");
+ });
+
+ it("buckets a legacy year_built into its band (mid-range)", () => {
+ expect(legacyAge("1985")).toBe("1983–1990");
+ });
+
+ it("buckets a legacy year before 1900 into band A", () => {
+ expect(legacyAge("1899")).toBe("before 1900");
+ });
+
+ it("buckets the first year of a band correctly (boundary)", () => {
+ expect(legacyAge("1900")).toBe("1900–1929");
+ });
+
+ it("buckets a recent legacy year into the open-ended final band", () => {
+ expect(legacyAge("2025")).toBe("2023 onwards");
+ });
+
+ it("resolves a non-numeric legacy year_built to 'Unknown'", () => {
+ expect(legacyAge("N/A")).toBe("Unknown");
+ });
+
+ it("resolves to 'Unknown' when nothing is available; ignores the legacy row for new-approach", () => {
+ expect(
+ resolveConstructionAge({
+ override: null,
+ isNewApproach: true,
+ lodgedAgeBand: null,
+ predictedAgeBand: null,
+ legacyYearBuilt: "1985", // must NOT surface for a new-approach property
+ }),
+ ).toBe("Unknown");
+ });
+
+ it("lets an explicit 'Unknown' override win", () => {
+ expect(
+ resolveConstructionAge({
+ override: "Unknown",
+ isNewApproach: true,
+ lodgedAgeBand: "C",
+ predictedAgeBand: null,
+ legacyYearBuilt: null,
+ }),
+ ).toBe("Unknown");
+ });
+});
+
+describe("resolveMainFuel", () => {
+ const base = {
+ override: null,
+ isNewApproach: true,
+ lodgedMainFuel: null,
+ predictedMainFuel: null,
+ legacyMainFuel: null,
+ };
+
+ it("prefers a landlord override over the EPC-derived value", () => {
+ expect(
+ resolveMainFuel({ ...base, override: "mains gas", lodgedMainFuel: "26" }),
+ ).toBe("mains gas");
+ });
+
+ it("reads the new-approach EPC main-fuel code (lodged) as a raw value", () => {
+ expect(resolveMainFuel({ ...base, lodgedMainFuel: "26" })).toBe("26");
+ });
+
+ it("falls back to the predicted EPC main fuel when there is no lodged one", () => {
+ expect(resolveMainFuel({ ...base, predictedMainFuel: "29" })).toBe("29");
+ });
+
+ it("prefers the lodged EPC main fuel over the predicted one", () => {
+ expect(
+ resolveMainFuel({ ...base, lodgedMainFuel: "26", predictedMainFuel: "29" }),
+ ).toBe("26");
+ });
+
+ it("passes an EPR string main fuel through unchanged", () => {
+ expect(resolveMainFuel({ ...base, lodgedMainFuel: "Mains gas" })).toBe("Mains gas");
+ });
+
+ it("resolves to 'Unknown' for a new-approach property with no EPC main fuel; ignores the legacy row", () => {
+ expect(
+ resolveMainFuel({ ...base, legacyMainFuel: "Gas mains gas" }),
+ ).toBe("Unknown");
+ });
+
+ it("reads the legacy EPC main fuel for a legacy property", () => {
+ expect(
+ resolveMainFuel({
+ ...base,
+ isNewApproach: false,
+ lodgedMainFuel: "26", // must be ignored for legacy
+ legacyMainFuel: "Gas mains gas",
+ }),
+ ).toBe("Gas mains gas");
+ });
+
+ it("resolves to 'Unknown' when nothing is available (never null)", () => {
+ expect(resolveMainFuel({ ...base, isNewApproach: false })).toBe("Unknown");
+ });
+});
+
+describe("MAINFUEL_OPTIONS coverage", () => {
+ const covered = new Set(MAINFUEL_OPTIONS.flatMap((o) => o.dbValues));
+ const labels = new Set(MAINFUEL_OPTIONS.map((o) => o.label));
+
+ // Every landlord main-fuel override value must fold into a filter option, or an
+ // overridden fuel would display but be unfilterable (ADR-0012).
+ it("covers every landlord main-fuel override value", () => {
+ for (const value of MainFuelValues) {
+ expect(covered).toContain(value);
+ }
+ });
+
+ // Every RdSAP main_fuel code the new EPC graph can store must fold into a
+ // filter option under a real label (a typo'd label would be silently dropped
+ // by the MAINFUEL_OPTIONS merge — assert both the code AND its label).
+ it("folds every RdSAP main_fuel code under a real label", () => {
+ for (const [code, label] of Object.entries(RDSAP_MAIN_FUEL_CODE_LABELS)) {
+ expect(labels).toContain(label);
+ expect(covered).toContain(code);
+ }
+ });
+
+ // Every EPR free-text main_fuel string must fold in too.
+ it("folds every EPR main-fuel string under a real label", () => {
+ for (const [str, label] of Object.entries(EPR_MAIN_FUEL_STRING_LABELS)) {
+ expect(labels).toContain(label);
+ expect(covered).toContain(str);
+ }
+ });
+});
+
+describe("resolveOverrideDescriptor (wall / roof / heating free-text)", () => {
+ const base = {
+ override: null,
+ isNewApproach: true,
+ lodgedDescription: null,
+ predictedDescription: null,
+ legacyDescription: null,
+ };
+
+ it("prefers a landlord override over the EPC description", () => {
+ expect(
+ resolveOverrideDescriptor({
+ ...base,
+ override: "Cavity wall, filled cavity",
+ lodgedDescription: "Solid brick, as built, no insulation (assumed)",
+ }),
+ ).toBe("Cavity wall, filled cavity");
+ });
+
+ it("uses the lodged EPC description when there is no override", () => {
+ expect(
+ resolveOverrideDescriptor({
+ ...base,
+ lodgedDescription: "Pitched, 250 mm loft insulation",
+ }),
+ ).toBe("Pitched, 250 mm loft insulation");
+ });
+
+ it("falls back to the predicted EPC description when there is no lodged one", () => {
+ expect(
+ resolveOverrideDescriptor({ ...base, predictedDescription: "Flat, insulated (assumed)" }),
+ ).toBe("Flat, insulated (assumed)");
+ });
+
+ it("reads the legacy description for a legacy property", () => {
+ expect(
+ resolveOverrideDescriptor({
+ ...base,
+ isNewApproach: false,
+ lodgedDescription: "ignored for legacy",
+ legacyDescription: "Boiler and radiators, mains gas",
+ }),
+ ).toBe("Boiler and radiators, mains gas");
+ });
+
+ it("resolves to 'Unknown' when nothing is available; ignores legacy for new-approach", () => {
+ expect(
+ resolveOverrideDescriptor({ ...base, legacyDescription: "must not surface" }),
+ ).toBe("Unknown");
+ });
+});
+
+describe("classifyDescriptor — wall / roof / heating buckets", () => {
+ const wall = (v: string) =>
+ classifyDescriptor(v, WALL_TYPE_OPTIONS, DESCRIPTOR_FILTER_CONFIG.wallType.match);
+ const roof = (v: string) =>
+ classifyDescriptor(v, ROOF_TYPE_OPTIONS, DESCRIPTOR_FILTER_CONFIG.roofType.match);
+ const heat = (v: string) =>
+ classifyDescriptor(v, HEATING_SYSTEM_OPTIONS, DESCRIPTOR_FILTER_CONFIG.heatingSystem.match);
+
+ // Every landlord override value must fall into a real (non-Unknown) bucket, or
+ // an overridden component would display but be unfilterable (ADR-0012). The
+ // literal "Unknown" is the sole exception — it maps to the Unknown bucket.
+ const assertVocabCovered = (
+ values: readonly string[],
+ classify: (v: string) => string,
+ labels: Set,
+ ) => {
+ for (const value of values) {
+ const bucket = classify(value);
+ expect(labels).toContain(bucket);
+ if (value !== "Unknown") expect(bucket).not.toBe("Unknown");
+ }
+ };
+
+ it("buckets every WallType override value", () => {
+ assertVocabCovered(WallTypeValues, wall, new Set(WALL_TYPE_OPTIONS.map((b) => b.label)));
+ });
+ it("buckets every RoofType override value", () => {
+ assertVocabCovered(RoofTypeValues, roof, new Set(ROOF_TYPE_OPTIONS.map((b) => b.label)));
+ });
+ it("buckets every MainHeatingSystem override value", () => {
+ assertVocabCovered(
+ MainHeatingSystemValues,
+ heat,
+ new Set(HEATING_SYSTEM_OPTIONS.map((b) => b.label)),
+ );
+ });
+
+ // Representative EPC / legacy descriptions (from production) bucket as expected.
+ it("buckets representative EPC/legacy WALL descriptions", () => {
+ expect(wall("Cavity wall, filled cavity")).toBe("Cavity");
+ expect(wall("Solid brick, as built, no insulation (assumed)")).toBe("Solid Brick");
+ expect(wall("Timber frame, as built, insulated (assumed)")).toBe("Timber Frame");
+ expect(wall("Sandstone or limestone, as built, no insulation (assumed)")).toBe("Stone");
+ expect(wall("Granite or whinstone, as built, no insulation (assumed)")).toBe("Stone");
+ expect(wall("System built, with external insulation")).toBe("System Built");
+ // A bare U-value is not a construction type → Unknown.
+ expect(wall("Average thermal transmittance 0.21 W/m²K")).toBe("Unknown");
+ });
+
+ it("buckets representative EPC/legacy ROOF descriptions", () => {
+ expect(roof("Pitched, 200 mm loft insulation")).toBe("Pitched");
+ expect(roof("Flat, no insulation (assumed)")).toBe("Flat");
+ expect(roof("Roof room(s), insulated (assumed)")).toBe("Room-in-Roof");
+ expect(roof("(another dwelling above)")).toBe("Premises Above");
+ expect(roof("(other premises above)")).toBe("Premises Above");
+ expect(roof("Another Premises Above")).toBe("Premises Above");
+ expect(roof("Average thermal transmittance 0.11 W/m²K")).toBe("Unknown");
+ });
+
+ it("buckets representative EPC/legacy HEATING descriptions", () => {
+ expect(heat("Boiler and radiators, mains gas")).toBe("Gas Boiler");
+ expect(heat("Room heaters, mains gas")).toBe("Gas Room Heater");
+ expect(heat("Community scheme")).toBe("Community");
+ expect(heat("Community scheme, biomass")).toBe("Community");
+ expect(heat("Electric storage heaters")).toBe("Electric Storage");
+ expect(heat("Room heaters, electric")).toBe("Direct Electric");
+ expect(heat("Air source heat pump, radiators, electric")).toBe("Heat Pump");
+ // "oil" is a substring of "boiler" — a gas boiler must NOT bucket as Oil.
+ expect(heat("Boiler and radiators, oil")).toBe("Oil");
+ expect(heat("Boiler and radiators, dual fuel (mineral and wood)")).toBe("Solid Fuel");
+ expect(heat("Boiler and radiators, lpg")).toBe("LPG");
+ });
+});
+
+/** Legacy-property helper: only year_built is set, cutoff is false. */
+function legacyAge(year: string): string {
+ return resolveConstructionAge({
+ override: null,
+ isNewApproach: false,
+ lodgedAgeBand: null,
+ predictedAgeBand: null,
+ legacyYearBuilt: year,
+ });
+}
diff --git a/src/lib/services/descriptorResolution.ts b/src/lib/services/descriptorResolution.ts
new file mode 100644
index 00000000..da166b64
--- /dev/null
+++ b/src/lib/services/descriptorResolution.ts
@@ -0,0 +1,179 @@
+/**
+ * Pure precedence resolvers for the portfolio-list property descriptors.
+ *
+ * Mirrors the provenance.ts split: the DB query gathers the raw inputs (landlord
+ * override snapshot, lodged/predicted EPC values, legacy property-row value) and
+ * these functions own the precedence + RdSAP code→label mapping. The SQL twins
+ * in epcSources.ts (resolvedPropertyTypeSql, …) mirror this logic — keep in sync.
+ *
+ * Precedence (ADR-0008, extended to the list by ADR-0012):
+ * landlord override → EPC-derived (lodged over predicted, codes mapped;
+ * legacy property-row fallback) → 'Unknown' (never null)
+ */
+import {
+ BUILT_FORM_LABELS,
+ CONSTRUCTION_AGE_BANDS,
+ PROPERTY_TYPE_LABELS,
+} from "./epcSources";
+
+export interface PropertyTypeInputs {
+ /** property_overrides.override_value for component 'property_type', building_part 0. */
+ override: string | null;
+ /** Whether the property reads the new EPC graph (updated_at >= cutoff). */
+ isNewApproach: boolean;
+ /** epc_property(source='lodged').property_type — RdSAP code or text. */
+ lodgedPropertyType: string | null;
+ /** epc_property(source='lodged').dwelling_type — fallback when property_type is absent. */
+ lodgedDwellingType: string | null;
+ predictedPropertyType: string | null;
+ predictedDwellingType: string | null;
+ /** property.property_type — the legacy row value. */
+ legacyPropertyType: string | null;
+}
+
+export function resolvePropertyType(i: PropertyTypeInputs): string {
+ if (i.override) return i.override;
+ const derived = i.isNewApproach
+ ? epcPropertyType(i.lodgedPropertyType, i.lodgedDwellingType) ??
+ epcPropertyType(i.predictedPropertyType, i.predictedDwellingType)
+ : i.legacyPropertyType;
+ return derived ?? "Unknown";
+}
+
+/**
+ * One EPC source's property-type label: the RdSAP code mapped to a label (text
+ * passes through), falling back to dwelling_type. Mirrors epcPropertyTypeSql.
+ */
+function epcPropertyType(
+ propertyType: string | null,
+ dwellingType: string | null,
+): string | null {
+ if (propertyType != null) return PROPERTY_TYPE_LABELS[propertyType] ?? propertyType;
+ return dwellingType;
+}
+
+export interface BuiltFormInputs {
+ /** property_overrides.override_value for component 'built_form_type', building_part 0. */
+ override: string | null;
+ isNewApproach: boolean;
+ /** epc_property(source='lodged').built_form — RdSAP code or text. */
+ lodgedBuiltForm: string | null;
+ predictedBuiltForm: string | null;
+ /** property.built_form — the legacy row value. */
+ legacyBuiltForm: string | null;
+}
+
+export function resolveBuiltForm(i: BuiltFormInputs): string {
+ if (i.override) return i.override;
+ const derived = i.isNewApproach
+ ? epcBuiltForm(i.lodgedBuiltForm) ?? epcBuiltForm(i.predictedBuiltForm)
+ : i.legacyBuiltForm;
+ return derived ?? "Unknown";
+}
+
+/** One EPC source's built-form label: RdSAP code → label, text passes through. Mirrors builtFormTypeSql. */
+function epcBuiltForm(builtForm: string | null): string | null {
+ if (builtForm == null) return null;
+ return BUILT_FORM_LABELS[builtForm] ?? builtForm;
+}
+
+export interface ConstructionAgeInputs {
+ /** property_overrides.override_value for 'construction_age_band', building_part 0 — an RdSAP letter (A..M) or "Unknown". */
+ override: string | null;
+ isNewApproach: boolean;
+ /** The main building part's epc_building_part.construction_age_band — an RdSAP letter. */
+ lodgedAgeBand: string | null;
+ predictedAgeBand: string | null;
+ /** property.year_built — a raw year string (legacy). Bucketed into a band. */
+ legacyYearBuilt: string | null;
+}
+
+/**
+ * Construction age as an RdSAP band LABEL ("before 1900" … "2023 onwards",
+ * "Unknown") — the band is the underlying datum, never a single year (ADR-0012).
+ * Override and EPC both store the band letter; legacy year_built is bucketed into
+ * a band. Mirrors resolvedConstructionAgeSql.
+ */
+export function resolveConstructionAge(i: ConstructionAgeInputs): string {
+ if (i.override) return bandLetterToLabel(i.override);
+ const band = i.isNewApproach
+ ? i.lodgedAgeBand ?? i.predictedAgeBand
+ : bucketLegacyYearToBand(i.legacyYearBuilt);
+ return band != null ? bandLetterToLabel(band) : "Unknown";
+}
+
+/** RdSAP band letter → band label; unrecognised values (e.g. "Unknown") pass through. */
+function bandLetterToLabel(letter: string): string {
+ return CONSTRUCTION_AGE_BANDS[letter]?.label ?? letter;
+}
+
+/**
+ * Bucket a legacy raw year_built into its RdSAP band letter: the band with the
+ * greatest start year not after the given year. Non-numeric text → null (Unknown);
+ * a year below the earliest start is pre-1900 → band A. Mirrors the legacy branch
+ * of resolvedConstructionAgeSql.
+ */
+export interface OverrideDescriptorInputs {
+ /** property_overrides.override_value for this component, building_part 0. */
+ override: string | null;
+ isNewApproach: boolean;
+ /** epc_energy_element.description for the element on the lodged EPC. */
+ lodgedDescription: string | null;
+ predictedDescription: string | null;
+ /** The legacy property_details_epc column (walls / roof / heating). */
+ legacyDescription: string | null;
+}
+
+/**
+ * Free-text component descriptor (wall type / roof type / heating system):
+ * override → EPC-derived (lodged over predicted, from epc_energy_element) →
+ * legacy property_details_epc column → 'Unknown'. No code→label mapping — the
+ * value is the description string itself. Mirrors resolvedWallTypeSql etc.
+ */
+export function resolveOverrideDescriptor(i: OverrideDescriptorInputs): string {
+ if (i.override) return i.override;
+ const derived = i.isNewApproach
+ ? i.lodgedDescription ?? i.predictedDescription
+ : i.legacyDescription;
+ return derived ?? "Unknown";
+}
+
+export interface MainFuelInputs {
+ /** property_overrides.override_value for component 'main_fuel', building_part 0. */
+ override: string | null;
+ isNewApproach: boolean;
+ /** epc_main_heating_detail.main_fuel_type scalar on the lodged EPC — an RdSAP code ("26") or an EPR string ("Mains gas"). */
+ lodgedMainFuel: string | null;
+ predictedMainFuel: string | null;
+ /** property_details_epc.mainfuel — the raw legacy EPC string. */
+ legacyMainFuel: string | null;
+}
+
+/**
+ * Main fuel raw value (folded to a label by the cell's resolveEnumLabel):
+ * override → EPC-derived (new: epc_main_heating_detail scalar, lodged over
+ * predicted; legacy: the property_details_epc string) → 'Unknown'. The
+ * new-approach scalar is an RdSAP `main_fuel` code or an EPR string; both fold
+ * into MAINFUEL_OPTIONS. Never null → 'Unknown'. Mirrors resolvedMainFuelSql.
+ */
+export function resolveMainFuel(i: MainFuelInputs): string {
+ if (i.override) return i.override;
+ const derived = i.isNewApproach
+ ? i.lodgedMainFuel ?? i.predictedMainFuel
+ : i.legacyMainFuel;
+ return derived ?? "Unknown";
+}
+
+function bucketLegacyYearToBand(yearBuilt: string | null): string | null {
+ if (yearBuilt == null || !/^[0-9]+$/.test(yearBuilt)) return null;
+ const year = parseInt(yearBuilt, 10);
+ let best: string | null = null;
+ let bestStart = -Infinity;
+ for (const [letter, { year: start }] of Object.entries(CONSTRUCTION_AGE_BANDS)) {
+ if (start <= year && start > bestStart) {
+ best = letter;
+ bestStart = start;
+ }
+ }
+ return best ?? "A";
+}
diff --git a/src/lib/services/epcSlot.test.ts b/src/lib/services/epcSlot.test.ts
new file mode 100644
index 00000000..bd2679a7
--- /dev/null
+++ b/src/lib/services/epcSlot.test.ts
@@ -0,0 +1,104 @@
+import { describe, expect, it } from "vitest";
+import { PgDialect } from "drizzle-orm/pg-core";
+import { sql } from "drizzle-orm";
+import {
+ newApproachJoins,
+ estimatedSql,
+ withoutEpcSql,
+ isExpiredSql,
+ provenanceSignalSql,
+} from "./epcSources";
+
+/**
+ * `epc_property.source` has three values: `lodged`, and the two flavours of the
+ * predicted slot — `predicted` (gap-filled blind) and `expired` (gap-filled, but
+ * conditioned on the dwelling's own expired pre-2012 certificate; Model ADR-0054).
+ *
+ * These tests exist because of a specific, silent failure: every EPC expression
+ * used to match `source = 'predicted'` alone. An `expired` row then matched
+ * neither the lodged nor the predicted alias, so the home read as though it had a
+ * valid current certificate and vanished from BOTH the "Homes Without an EPC" and
+ * "Expired EPCs" cards. `epc_property.source` is plain `text` with no enum or CHECK
+ * constraint, so nothing at the database level would have caught it.
+ *
+ * They assert on rendered SQL rather than query results because the repo has no
+ * database harness — structural, but they pin the exact invariant that broke.
+ */
+
+const dialect = new PgDialect();
+const render = (fragment: ReturnType) =>
+ dialect.sqlToQuery(fragment).sql;
+
+// A zero-interpolation fragment renders empty on its own, so embed it.
+const renderJoins = () => render(sql`SELECT 1 ${newApproachJoins}`);
+
+describe("newApproachJoins", () => {
+ it("joins all three sources, so no epc_property row is invisible", () => {
+ const joins = renderJoins();
+ expect(joins).toContain("epl.source = 'lodged'");
+ expect(joins).toContain("epp.source = 'predicted'");
+ expect(joins).toContain("epx.source = 'expired'");
+ });
+});
+
+describe("estimatedSql — 'was this picture modelled?'", () => {
+ it("counts BOTH flavours of the predicted slot as estimated", () => {
+ // An expired-conditioned prediction is still a prediction: it must carry the
+ // Estimated provenance signal, not read as a real certificate.
+ expect(render(estimatedSql(sql`e`))).toContain(
+ "(epl.id IS NULL AND (epp.id IS NOT NULL OR epx.id IS NOT NULL))",
+ );
+ });
+});
+
+describe("withoutEpcSql — 'does any certificate exist?'", () => {
+ it("requires neither a lodged nor a historical record", () => {
+ expect(render(withoutEpcSql(sql`e`))).toContain(
+ "(epl.id IS NULL AND epx.id IS NULL)",
+ );
+ });
+
+ it("does not consult the blind-predicted row: a prediction is not a certificate", () => {
+ // A home with only a `predicted` row has no EPC anywhere — that is precisely
+ // what makes it "without an EPC", so `epp` must not appear as evidence of one.
+ expect(render(withoutEpcSql(sql`e`))).not.toContain("epp");
+ });
+
+ it("is a different question from estimatedSql", () => {
+ // The bug was treating these as synonyms. An `expired` home is estimated AND
+ // has an EPC, so the two predicates must disagree about it.
+ expect(render(withoutEpcSql(sql`e`))).not.toEqual(render(estimatedSql(sql`e`)));
+ });
+});
+
+describe("isExpiredSql — 'we found a certificate and it is out of date'", () => {
+ it("treats an expired-source row as expired by construction", () => {
+ // ADR-0054: an `expired` row is only ever written when the conditioning
+ // certificate predates 2012, so it is >10 years old by definition.
+ expect(render(isExpiredSql(sql`e`))).toContain("epx.id IS NOT NULL");
+ });
+
+ it("falls back to inspection_date when the lodged cert has no registration_date", () => {
+ // Reading registration_date alone silently counted date-less lodged certs as
+ // current; lodgementDateSql already coalesces the same way.
+ expect(render(isExpiredSql(sql`e`))).toContain(
+ "COALESCE(epl.registration_date, epl.inspection_date)",
+ );
+ });
+
+ it("excludes gap-filled legacy rows — nothing to expire without a certificate", () => {
+ expect(render(isExpiredSql(sql`e`))).toContain(
+ "NOT COALESCE(e.estimated, false)",
+ );
+ });
+});
+
+describe("provenanceSignalSql", () => {
+ it("shows the Estimated badge for both flavours of the predicted slot", () => {
+ // Without epx here, an expired-conditioned home would render with no badge at
+ // all, as though its picture came off a real current certificate.
+ expect(render(provenanceSignalSql)).toContain(
+ "(epp.id IS NOT NULL OR epx.id IS NOT NULL) AND epl.id IS NULL",
+ );
+ });
+});
diff --git a/src/lib/services/epcSources.test.ts b/src/lib/services/epcSources.test.ts
index 1d85a6ab..5b859fd9 100644
--- a/src/lib/services/epcSources.test.ts
+++ b/src/lib/services/epcSources.test.ts
@@ -3,7 +3,10 @@ import {
CONSTRUCTION_AGE_BANDS,
PROPERTY_TYPE_LABELS,
} from "./epcSources";
-import { PROPERTY_TYPE_OPTIONS } from "@/app/utils/propertyFilters";
+import {
+ PROPERTY_TYPE_OPTIONS,
+ YEAR_BUILT_OPTIONS,
+} from "@/app/utils/propertyFilters";
// The reporting age-band bucketing in getCountByAgeBand (databaseFunctions.ts),
// mirrored so the CONSTRUCTION_AGE_BANDS representative years stay anchored to
@@ -57,12 +60,26 @@ describe("CONSTRUCTION_AGE_BANDS", () => {
});
describe("PROPERTY_TYPE_LABELS", () => {
- it("maps codes to the labels the property-type filter options use", () => {
+ it("maps every code to a label the property-type filter offers as an option", () => {
const optionLabels = new Set(PROPERTY_TYPE_OPTIONS.map((o) => o.label));
for (const label of Object.values(PROPERTY_TYPE_LABELS)) {
- // Park home has no filter option — it's rare and charts render it as-is.
- if (label === "Park home") continue;
expect(optionLabels).toContain(label);
}
});
});
+
+describe("YEAR_BUILT_OPTIONS (Construction Age)", () => {
+ // Guards the band-native filter (ADR-0012) against label drift — a mismatched
+ // en-dash or reworded band would silently make the filter match nothing.
+ it("is exactly the RdSAP band labels in order, plus Unknown", () => {
+ const bandLabels = Object.values(CONSTRUCTION_AGE_BANDS).map((b) => b.label);
+ expect(YEAR_BUILT_OPTIONS.map((o) => o.label)).toEqual([
+ ...bandLabels,
+ "Unknown",
+ ]);
+ });
+
+ it("uses each band label as its own dbValue", () => {
+ for (const o of YEAR_BUILT_OPTIONS) expect(o.dbValues).toEqual([o.label]);
+ });
+});
diff --git a/src/lib/services/epcSources.ts b/src/lib/services/epcSources.ts
index b47ef438..5c47b471 100644
--- a/src/lib/services/epcSources.ts
+++ b/src/lib/services/epcSources.ts
@@ -70,11 +70,33 @@ type Alias = ReturnType;
/** TRUE for new-approach rows. */
export const isNewApproachSql = sql`p.updated_at >= ${NEW_APPROACH_CUTOFF}::date`;
-/** LEFT JOINs that expose the new sources alongside the legacy table. */
+/**
+ * LEFT JOINs that expose the new sources alongside the legacy table.
+ *
+ * `epc_property.source` has three values, not two. `lodged` is a real certificate.
+ * The other two share one slot — the *predicted slot* — and are both gap-fills:
+ *
+ * - `predicted` — synthesised blind from the postcode cohort. Nothing is known
+ * about this dwelling's own energy performance; there is no certificate for it
+ * anywhere.
+ * - `expired` — synthesised, but conditioned on the dwelling's own expired
+ * pre-2012 certificate from the historic register (Model ADR-0054). The gov EPC
+ * API only serves certificates registered since 2012, so these dwellings look
+ * EPC-less to ingestion even though a real, stale certificate exists.
+ *
+ * That distinction is the whole point: a home with an `expired` row **has** an EPC
+ * (an expired one); a home with only a `predicted` row has none at all.
+ *
+ * Matching `source = 'predicted'` alone would silently drop every `expired` row —
+ * it would match neither `epl` nor `epp`, and the home would read as though it had
+ * a valid current certificate. Address the *slot* (`epp` OR `epx`), never one member.
+ * Mirrors PREDICTED_SLOT_SOURCES in the Model repo.
+ */
export const newApproachJoins = sql`
LEFT JOIN property_baseline_performance bp ON bp.property_id = p.id
LEFT JOIN epc_property epl ON epl.property_id = p.id AND epl.source = 'lodged'
LEFT JOIN epc_property epp ON epp.property_id = p.id AND epp.source = 'predicted'
+ LEFT JOIN epc_property epx ON epx.property_id = p.id AND epx.source = 'expired'
`;
/**
@@ -133,7 +155,7 @@ export const lodgedSapSql = sql`CASE WHEN ${isNewApproachSql} THEN (CASE WHEN ep
export const provenanceSignalSql = sql`CASE
WHEN ${isNewApproachSql} THEN (
CASE
- WHEN epp.id IS NOT NULL AND epl.id IS NULL THEN 'estimated'
+ WHEN (epp.id IS NOT NULL OR epx.id IS NOT NULL) AND epl.id IS NULL THEN 'estimated'
WHEN epl.id IS NOT NULL AND bp.rebaseline_reason IS NOT NULL AND bp.rebaseline_reason <> 'none' THEN 'remodelled'
ELSE 'none'
END
@@ -180,22 +202,87 @@ export const lodgementDateSql = (e: Alias) =>
sql`CASE WHEN ${isNewApproachSql} THEN COALESCE(epl.registration_date, epl.inspection_date) ELSE ${e}.lodgement_date END`;
/**
- * "estimated" boolean. New: the property only has a predicted EPC (no lodged
- * row). Legacy: e.estimated.
+ * "estimated" — is this property's EPC picture a gap-fill rather than a real
+ * certificate? True for *either* flavour of the predicted slot: a blind
+ * `predicted` and a cert-conditioned `expired` are both synthesised, so both
+ * carry the Estimated provenance signal.
+ *
+ * This answers "was it modelled?", NOT "does a certificate exist?" — an `expired`
+ * property is estimated AND has an (expired) certificate. For the latter question
+ * use `withoutEpcSql`. Conflating the two is what made the reporting cards wrong.
+ *
+ * Legacy: e.estimated.
*/
export const estimatedSql = (e: Alias) =>
- sql`CASE WHEN ${isNewApproachSql} THEN (epl.id IS NULL AND epp.id IS NOT NULL) ELSE COALESCE(${e}.estimated, false) END`;
+ sql`CASE WHEN ${isNewApproachSql} THEN (epl.id IS NULL AND (epp.id IS NOT NULL OR epx.id IS NOT NULL)) ELSE COALESCE(${e}.estimated, false) END`;
/**
- * "expired" boolean. New: derived from the lodged EPC age (>10 years), since the
- * new graph stores no is_expired flag. Legacy: e.is_expired.
+ * "no EPC at all" — we found neither a lodgement record nor a historical one, so
+ * nothing has ever been certified for this dwelling and its picture was gap-filled
+ * blind. This is the "Homes Without an EPC" card.
+ *
+ * Note a plain `predicted` row does not make a property "with" an EPC — a
+ * prediction is not a certificate. Only `lodged` (a current cert) or `expired` (a
+ * historical cert we conditioned on) count as having one. A property with no
+ * epc_property rows at all also lands here, which is right: it too has no EPC.
+ *
+ * Legacy: the flat `estimated` flag, which meant exactly this before the register
+ * had a historical tier to distinguish.
+ */
+export const withoutEpcSql = (e: Alias) =>
+ sql`CASE WHEN ${isNewApproachSql} THEN (epl.id IS NULL AND epx.id IS NULL) ELSE COALESCE(${e}.estimated, false) END`;
+
+/**
+ * "expired" — we found a certificate, of one kind or the other, and it is out of
+ * date. Two ways that happens:
+ *
+ * - an `expired` row exists: by construction (Model ADR-0054) it was conditioned
+ * on a pre-2012 certificate, which is >10 years old by definition; or
+ * - the lodged certificate is itself more than 10 years old.
+ *
+ * The lodged date falls back to `inspection_date` when `registration_date` is null —
+ * a sizeable minority of lodged rows carry only the former, and reading
+ * registration_date alone silently counted them as current. `lodgementDateSql`
+ * above already coalesces the same way.
+ *
+ * A blindly-`predicted` property is never expired: it has no certificate to expire.
+ * Legacy: e.is_expired, less the gap-filled rows (same reason).
*/
export const isExpiredSql = (e: Alias) =>
- sql`CASE WHEN ${isNewApproachSql} THEN (epl.registration_date IS NOT NULL AND epl.registration_date < (CURRENT_DATE - INTERVAL '10 years')) ELSE ${e}.is_expired END`;
+ sql`CASE WHEN ${isNewApproachSql} THEN (
+ epx.id IS NOT NULL
+ OR COALESCE(epl.registration_date, epl.inspection_date) < (CURRENT_DATE - INTERVAL '10 years')
+ ) ELSE (${e}.is_expired AND NOT COALESCE(${e}.estimated, false)) END`;
-/** Main fuel. GAP for new properties (no clean equivalent) → NULL. Legacy: e.mainfuel. */
+/**
+ * The main-fuel scalar for one epc_property alias, read from the JSONB
+ * `epc_main_heating_detail.main_fuel_type` as a correlated subquery. The stored
+ * scalar is either a numeric RdSAP `main_fuel` code ("26", "29", … — ~95% of
+ * rows, from the gov-EPC API) or an EPR text string ("Mains gas", "Bulk LPG", …
+ * from Elmhurst/PASHub). `#>> '{}'` extracts the JSON scalar as text; NULLIF
+ * drops the empty-string sentinel to NULL. Codes/strings are folded to a label
+ * downstream by MAINFUEL_OPTIONS — the fragment emits the raw value, like
+ * resolvedMainFuelSql's legacy branch. (No index on epc_property_id yet — see
+ * ix_epc_main_heating_detail_epc_property in the schema.)
+ */
+const epcMainFuelSql = (ep: Alias) => sql`(
+ SELECT NULLIF(mhd.main_fuel_type #>> '{}', '')
+ FROM epc_main_heating_detail mhd
+ WHERE mhd.epc_property_id = ${ep}.id
+ LIMIT 1
+)`;
+
+/**
+ * Main fuel raw value. New: the epc_main_heating_detail scalar (lodged over
+ * predicted) — an RdSAP code or an EPR string, folded to a label by
+ * MAINFUEL_OPTIONS. Legacy: e.mainfuel. Mirrors the new-approach branch of
+ * resolveMainFuel.
+ */
export const mainfuelSql = (e: Alias) =>
- sql`CASE WHEN ${isNewApproachSql} THEN NULL ELSE ${e}.mainfuel END`;
+ sql`CASE
+ WHEN ${isNewApproachSql} THEN (CASE WHEN epl.id IS NOT NULL THEN ${epcMainFuelSql(sql`epl`)} ELSE ${epcMainFuelSql(sql`epp`)} END)
+ ELSE ${e}.mainfuel
+ END`;
// ─────────────────────────────────────────────────────────────────────────────
// RdSAP code → label maps for the descriptive fields the new pipeline stores as
@@ -273,6 +360,108 @@ export const builtFormTypeSql = sql`CASE
ELSE p.built_form
END`;
+// ─────────────────────────────────────────────────────────────────────────────
+// Landlord-override-resolved descriptors (ADR-0012). Each fragment wraps the
+// EPC-derived expression above with the property_overrides snapshot and a
+// never-null 'Unknown' terminal — the same precedence previewModellingRun
+// applies (override → EPC-derived → Unknown). The TS twins in
+// descriptorResolution.ts (resolvePropertyType, …) own and unit-test this
+// precedence; keep the two in sync.
+//
+// A resolved fragment references an override alias that its join provides — add
+// the matching *OverrideJoin to any query that selects/filters on the fragment.
+// Overrides are whole-dwelling for these components, so the join pins
+// building_part = 0 (the main building) and never multiplies rows.
+// ─────────────────────────────────────────────────────────────────────────────
+
+/** LEFT JOIN exposing the property_type override snapshot (alias `pot`). */
+export const propertyTypeOverrideJoin = sql`
+ LEFT JOIN property_overrides pot
+ ON pot.property_id = p.id
+ AND pot.override_component = 'property_type'
+ AND pot.building_part = 0
+`;
+
+/** property_type: override → EPC-derived → 'Unknown'. Mirrors resolvePropertyType. */
+export const resolvedPropertyTypeSql = sql`COALESCE(pot.override_value, ${propertyTypeSql}, 'Unknown')`;
+
+/** LEFT JOIN exposing the built_form_type override snapshot (alias `pobf`). */
+export const builtFormOverrideJoin = sql`
+ LEFT JOIN property_overrides pobf
+ ON pobf.property_id = p.id
+ AND pobf.override_component = 'built_form_type'
+ AND pobf.building_part = 0
+`;
+
+/** built_form: override → EPC-derived → 'Unknown'. Mirrors resolveBuiltForm. */
+export const resolvedBuiltFormSql = sql`COALESCE(pobf.override_value, ${builtFormTypeSql}, 'Unknown')`;
+
+/** LEFT JOIN exposing the main_fuel override snapshot (alias `pmf`). */
+export const mainFuelOverrideJoin = sql`
+ LEFT JOIN property_overrides pmf
+ ON pmf.property_id = p.id
+ AND pmf.override_component = 'main_fuel'
+ AND pmf.building_part = 0
+`;
+
+/**
+ * main fuel (raw value; folded to a label by the cell's resolveEnumLabel):
+ * override → EPC-derived → 'Unknown'. The new EPC graph has no main fuel, so
+ * mainfuelSql is NULL for new-approach — the override is the only new-approach
+ * source. Takes the legacy `property_details_epc` alias. Mirrors resolveMainFuel.
+ */
+export const resolvedMainFuelSql = (e: Alias) =>
+ sql`COALESCE(pmf.override_value, ${mainfuelSql(e)}, 'Unknown')`;
+
+// ─── Free-text component descriptors: wall / roof / heating (ADR-0012) ────────
+// override → EPC-derived (epc_energy_element description, lodged over predicted)
+// → legacy property_details_epc column → 'Unknown'. Mirrors resolveOverrideDescriptor.
+
+/** One EPC source's description for an energy element, as a correlated subquery. */
+const epcElementDescSql = (ep: Alias, elementType: string) => sql`(
+ SELECT ee.description FROM epc_energy_element ee
+ WHERE ee.epc_property_id = ${ep}.id AND ee.element_type = ${elementType}
+ LIMIT 1
+)`;
+
+/** EPC-or-legacy element description: new = lodged over predicted; legacy = the property_details_epc column. */
+const epcElementSql = (elementType: string, legacyCol: Alias) => sql`CASE
+ WHEN ${isNewApproachSql} THEN (CASE WHEN epl.id IS NOT NULL THEN ${epcElementDescSql(sql`epl`, elementType)} ELSE ${epcElementDescSql(sql`epp`, elementType)} END)
+ ELSE ${legacyCol}
+END`;
+
+/** LEFT JOIN exposing the wall_type override snapshot at the main building part (alias `pwall`). */
+export const wallTypeOverrideJoin = sql`
+ LEFT JOIN property_overrides pwall
+ ON pwall.property_id = p.id
+ AND pwall.override_component = 'wall_type'
+ AND pwall.building_part = 0
+`;
+/** LEFT JOIN exposing the roof_type override snapshot at the main building part (alias `proof`). */
+export const roofTypeOverrideJoin = sql`
+ LEFT JOIN property_overrides proof
+ ON proof.property_id = p.id
+ AND proof.override_component = 'roof_type'
+ AND proof.building_part = 0
+`;
+/** LEFT JOIN exposing the main_heating_system override snapshot (alias `pheat`). */
+export const mainHeatingOverrideJoin = sql`
+ LEFT JOIN property_overrides pheat
+ ON pheat.property_id = p.id
+ AND pheat.override_component = 'main_heating_system'
+ AND pheat.building_part = 0
+`;
+
+/** wall type: override → EPC 'wall' description → legacy walls → 'Unknown'. Mirrors resolveOverrideDescriptor. */
+export const resolvedWallTypeSql = (e: Alias) =>
+ sql`COALESCE(pwall.override_value, ${epcElementSql("wall", sql`${e}.walls`)}, 'Unknown')`;
+/** roof type: override → EPC 'roof' description → legacy roof → 'Unknown'. */
+export const resolvedRoofTypeSql = (e: Alias) =>
+ sql`COALESCE(proof.override_value, ${epcElementSql("roof", sql`${e}.roof`)}, 'Unknown')`;
+/** heating system: override → EPC 'main_heating' description → legacy heating → 'Unknown'. */
+export const resolvedHeatingSystemSql = (e: Alias) =>
+ sql`COALESCE(pheat.override_value, ${epcElementSql("main_heating", sql`${e}.heating`)}, 'Unknown')`;
+
/**
* The main building part's construction age band for one epc_property alias, as
* a correlated scalar subquery — properties can also have extension parts, so a
@@ -306,6 +495,52 @@ export const constructionYearSql = sql`CASE
ELSE NULL
END`;
+// ─── Construction age as a band LABEL (ADR-0012) ─────────────────────────────
+// Unlike constructionYearSql (which flattens the band to a representative year
+// for reporting buckets), the portfolio list keeps the band itself. Mirrors
+// resolveConstructionAge in descriptorResolution.ts — keep in sync.
+
+/** RdSAP band letter → band label (e.g. B → "1900–1929"). */
+const AGE_BAND_LABELS: Record = Object.fromEntries(
+ Object.entries(CONSTRUCTION_AGE_BANDS).map(([letter, { label }]) => [letter, label]),
+);
+
+/** Bucket a legacy year_built expression into its band label; non-numeric → NULL. */
+const legacyYearBandLabelSql = (yearExpr: Alias) => {
+ const y = sql`CAST(${yearExpr} AS int)`;
+ const thresholds = Object.entries(CONSTRUCTION_AGE_BANDS)
+ .filter(([letter]) => letter !== "A")
+ .sort((a, b) => b[1].year - a[1].year)
+ .map(([, { year, label }]) => sql`WHEN ${y} >= ${year} THEN ${label}`);
+ // The numeric guard fires the CAST only on digit strings; below the earliest
+ // band start falls through to band A.
+ return sql`CASE WHEN ${yearExpr} ~ '^[0-9]+$' THEN (CASE ${sql.join(
+ thresholds,
+ sql` `,
+ )} ELSE ${CONSTRUCTION_AGE_BANDS.A.label} END) ELSE NULL END`;
+};
+
+/** EPC-or-legacy band label: new-approach main-part band (lodged over predicted); legacy year bucketed. */
+const constructionAgeBandLabelSql = sql`CASE
+ WHEN ${isNewApproachSql} THEN (CASE WHEN epl.id IS NOT NULL THEN ${codeLabelCaseSql(mainPartAgeBandSql(sql`epl`), AGE_BAND_LABELS)} ELSE ${codeLabelCaseSql(mainPartAgeBandSql(sql`epp`), AGE_BAND_LABELS)} END)
+ ELSE ${legacyYearBandLabelSql(sql`p.year_built`)}
+END`;
+
+/** LEFT JOIN exposing the construction_age_band override snapshot (alias `pab`). */
+export const constructionAgeOverrideJoin = sql`
+ LEFT JOIN property_overrides pab
+ ON pab.property_id = p.id
+ AND pab.override_component = 'construction_age_band'
+ AND pab.building_part = 0
+`;
+
+/** construction age: override → EPC band → legacy year bucket → 'Unknown'. Mirrors resolveConstructionAge. */
+export const resolvedConstructionAgeSql = sql`COALESCE(
+ ${codeLabelCaseSql(sql`pab.override_value`, AGE_BAND_LABELS)},
+ ${constructionAgeBandLabelSql},
+ 'Unknown'
+)`;
+
// ─────────────────────────────────────────────────────────────────────────────
// Per-property resolvers (TypeScript object building).
// ─────────────────────────────────────────────────────────────────────────────
diff --git a/src/lib/tags/bulkAssign.test.ts b/src/lib/tags/bulkAssign.test.ts
new file mode 100644
index 00000000..a93c1a1a
--- /dev/null
+++ b/src/lib/tags/bulkAssign.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, it } from "vitest";
+import { parseTagIdentifierRows, MAX_BULK_TAG_ROWS } from "./bulkAssign";
+
+describe("parseTagIdentifierRows", () => {
+ it("extracts landlord property ids from a landlord_property_id column", () => {
+ const rows = [["landlord_property_id"], ["ABC-001"], ["ABC-002"]];
+ expect(parseTagIdentifierRows(rows)).toEqual({
+ ok: true,
+ key: "landlord_property_id",
+ identifiers: ["ABC-001", "ABC-002"],
+ });
+ });
+
+ it("detects a UPRN column (header normalised case-insensitively)", () => {
+ const rows = [["UPRN"], [100023336956], [100023336957]];
+ expect(parseTagIdentifierRows(rows)).toEqual({
+ ok: true,
+ key: "uprn",
+ identifiers: ["100023336956", "100023336957"],
+ });
+ });
+
+ it("normalises a spaced/cased header and trims + dedupes + drops blank ids", () => {
+ const rows = [
+ ["Landlord Property ID"],
+ [" ABC-001 "],
+ ["ABC-001"],
+ [""],
+ ["ABC-002"],
+ ];
+ expect(parseTagIdentifierRows(rows)).toEqual({
+ ok: true,
+ key: "landlord_property_id",
+ identifiers: ["ABC-001", "ABC-002"],
+ });
+ });
+
+ it("errors when neither identifier column is present", () => {
+ const rows = [["address", "postcode"], ["12 Oak St", "SW1"]];
+ expect(parseTagIdentifierRows(rows)).toEqual({
+ ok: false,
+ error:
+ "The file needs a 'landlord_property_id' or 'uprn' column in the first row",
+ });
+ });
+
+ it("errors on an empty file (no data rows)", () => {
+ expect(parseTagIdentifierRows([["uprn"]])).toEqual({
+ ok: false,
+ error: "The file has no rows to assign",
+ });
+ });
+
+ it("errors when the file exceeds the row cap", () => {
+ const rows: (string | number)[][] = [["uprn"]];
+ for (let i = 0; i < MAX_BULK_TAG_ROWS + 1; i++) rows.push([`1000${i}`]);
+ const result = parseTagIdentifierRows(rows);
+ expect(result.ok).toBe(false);
+ expect(result.ok === false && result.error).toContain(
+ String(MAX_BULK_TAG_ROWS),
+ );
+ });
+});
diff --git a/src/lib/tags/bulkAssign.ts b/src/lib/tags/bulkAssign.ts
new file mode 100644
index 00000000..10cd1cb0
--- /dev/null
+++ b/src/lib/tags/bulkAssign.ts
@@ -0,0 +1,61 @@
+/**
+ * Pure parsing for Bulk tag assignment (ADR-0013). The client reads the uploaded
+ * CSV/Excel into a 2D array of rows (header row first, via SheetJS) and this
+ * turns it into the identifier column to match on — either `landlord_property_id`
+ * or `uprn`, whichever header the file carries. Kept DB-free so it unit-tests and
+ * runs in the browser before anything is sent to the server.
+ */
+
+/** Upper bound on rows per upload ("relatively small file", ADR-0013). */
+export const MAX_BULK_TAG_ROWS = 10_000;
+
+export type IdentifierKey = "landlord_property_id" | "uprn";
+
+export type ParsedIdentifiers =
+ | { ok: true; key: IdentifierKey; identifiers: string[] }
+ | { ok: false; error: string };
+
+type Cell = string | number | null | undefined;
+
+/** Normalise a header cell: trimmed, lowercased, spaces/hyphens → underscores. */
+function normaliseHeader(cell: Cell): string {
+ return String(cell ?? "")
+ .trim()
+ .toLowerCase()
+ .replace(/[\s-]+/g, "_");
+}
+
+export function parseTagIdentifierRows(rows: Cell[][]): ParsedIdentifiers {
+ const [header, ...dataRows] = rows;
+ const headers = (header ?? []).map(normaliseHeader);
+
+ const keyIndex = headers.findIndex(
+ (h) => h === "landlord_property_id" || h === "uprn",
+ );
+ if (keyIndex === -1) {
+ return {
+ ok: false,
+ error:
+ "The file needs a 'landlord_property_id' or 'uprn' column in the first row",
+ };
+ }
+ const key = headers[keyIndex] as IdentifierKey;
+
+ const seen = new Set();
+ for (const row of dataRows) {
+ const value = String(row[keyIndex] ?? "").trim();
+ if (value.length > 0) seen.add(value);
+ }
+
+ if (seen.size === 0) {
+ return { ok: false, error: "The file has no rows to assign" };
+ }
+ if (seen.size > MAX_BULK_TAG_ROWS) {
+ return {
+ ok: false,
+ error: `The file has more than ${MAX_BULK_TAG_ROWS} properties — split it into smaller files`,
+ };
+ }
+
+ return { ok: true, key, identifiers: [...seen] };
+}
diff --git a/src/lib/tags/colour.test.ts b/src/lib/tags/colour.test.ts
new file mode 100644
index 00000000..90d5524d
--- /dev/null
+++ b/src/lib/tags/colour.test.ts
@@ -0,0 +1,82 @@
+import { describe, expect, it } from "vitest";
+import {
+ normaliseHex,
+ tagDotColour,
+ tagChipTokens,
+ luminance,
+} from "./colour";
+
+/** WCAG relative-luminance + contrast for asserting chip legibility in tests. */
+function lum(hex: string): number {
+ const n = hex.replace("#", "");
+ const [r, g, b] = [0, 2, 4].map((i) => {
+ const s = parseInt(n.slice(i, i + 2), 16) / 255;
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
+ });
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
+}
+function contrast(a: string, b: string): number {
+ const [la, lb] = [lum(a), lum(b)];
+ const [hi, lo] = la >= lb ? [la, lb] : [lb, la];
+ return (hi + 0.05) / (lo + 0.05);
+}
+
+describe("normaliseHex", () => {
+ it("lowercases, hashes, and expands 3-digit hex", () => {
+ expect(normaliseHex(" #FDE047 ")).toBe("#fde047");
+ expect(normaliseHex("#FFF")).toBe("#ffffff");
+ });
+ it("returns null for an unparseable colour", () => {
+ expect(normaliseHex("not-a-colour")).toBeNull();
+ });
+});
+
+describe("tagDotColour", () => {
+ it("returns the normalised hex", () => {
+ expect(tagDotColour("#7C3AED")).toBe("#7c3aed");
+ });
+ it("falls back to slate for garbage input", () => {
+ expect(tagDotColour("nope")).toBe("#64748b");
+ });
+});
+
+describe("luminance", () => {
+ it("ranks black below white", () => {
+ expect(luminance("#000000")).toBeLessThan(luminance("#ffffff"));
+ });
+});
+
+describe("tagChipTokens", () => {
+ it("builds a soft tint, border, dot, and readable ink", () => {
+ const t = tagChipTokens("#7c3aed");
+ expect(t.dot).toBe("#7c3aed");
+ // Both tint and border are blended over white, so lighter than the source;
+ // the border carries more of the colour, so it sits between tint and source.
+ expect(luminance(t.backgroundColor)).toBeGreaterThan(luminance("#7c3aed"));
+ expect(luminance(t.borderColor)).toBeGreaterThan(luminance("#7c3aed"));
+ expect(luminance(t.borderColor)).toBeLessThan(luminance(t.backgroundColor));
+ });
+
+ it("guarantees AA (≥4.5:1) ink for a hard, pale colour (yellow)", () => {
+ const t = tagChipTokens("#fde047");
+ expect(contrast(t.color, t.backgroundColor)).toBeGreaterThanOrEqual(4.5);
+ });
+
+ it("guarantees AA ink across a spread of freeform hues", () => {
+ for (const c of ["#ef4444", "#22c55e", "#3b82f6", "#000000", "#ffffff", "#14163d"]) {
+ const t = tagChipTokens(c);
+ expect(contrast(t.color, t.backgroundColor)).toBeGreaterThanOrEqual(4.5);
+ }
+ });
+
+ it("keeps a dark tag's ink close to its own hue (minimal darkening)", () => {
+ // Navy is already dark enough — ink should not collapse to pure black.
+ expect(tagChipTokens("#14163d").color).not.toBe("#000000");
+ });
+
+ it("falls back to a neutral chip for an unparseable colour", () => {
+ const t = tagChipTokens("garbage");
+ expect(t.dot).toBe("#64748b");
+ expect(contrast(t.color, t.backgroundColor)).toBeGreaterThanOrEqual(4.5);
+ });
+});
diff --git a/src/lib/tags/colour.ts b/src/lib/tags/colour.ts
new file mode 100644
index 00000000..88986148
--- /dev/null
+++ b/src/lib/tags/colour.ts
@@ -0,0 +1,113 @@
+/**
+ * Pure colour helpers for rendering Tag chips (ADR-0013). A Tag's colour is a
+ * freeform hex, so chips must stay calm and legible for ANY hue — the product is
+ * institutional and WCAG-AA (PRODUCT.md). The chip vocabulary is one system
+ * everywhere: a soft tint of the colour, a colour dot, and hue-preserving dark
+ * ink whose contrast against the tint is guaranteed ≥ 4.5:1. Kept DB-free +
+ * side-effect-free so it unit-tests cleanly and is shared by every chip surface.
+ */
+
+type Rgb = [number, number, number];
+
+/** Slate-500 — a neutral fallback for an unparseable colour. */
+const FALLBACK = "#64748b";
+/** Minimum WCAG contrast for the chip's ink against its tint background. */
+const MIN_CONTRAST = 4.5;
+
+/** Parse `#rgb` / `#rrggbb` (any case, surrounding space) → [r,g,b] 0-255, or null. */
+function parseHex(input: string): Rgb | null {
+ const hex = input.trim().toLowerCase().replace(/^#/, "");
+ const full =
+ hex.length === 3
+ ? hex.split("").map((c) => c + c).join("")
+ : hex;
+ if (!/^[0-9a-f]{6}$/.test(full)) return null;
+ return [
+ parseInt(full.slice(0, 2), 16),
+ parseInt(full.slice(2, 4), 16),
+ parseInt(full.slice(4, 6), 16),
+ ];
+}
+
+function toHex(rgb: Rgb): string {
+ return "#" + rgb.map((c) => Math.round(c).toString(16).padStart(2, "0")).join("");
+}
+
+/** Normalise a hex to lowercase `#rrggbb`, or null if unparseable. */
+export function normaliseHex(input: string): string | null {
+ const rgb = parseHex(input);
+ return rgb ? toHex(rgb) : null;
+}
+
+/** The dot colour for a Tag — its normalised hex, or a neutral fallback. */
+export function tagDotColour(colour: string): string {
+ return normaliseHex(colour) ?? FALLBACK;
+}
+
+function luminanceRgb([r, g, b]: Rgb): number {
+ const lin = [r, g, b].map((c) => {
+ const s = c / 255;
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
+ });
+ return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2];
+}
+
+/** Relative luminance (WCAG) of a hex colour, 0 → 1; unparseable → 1 (light). */
+export function luminance(input: string): number {
+ const rgb = parseHex(input);
+ return rgb ? luminanceRgb(rgb) : 1;
+}
+
+function contrast(a: Rgb, b: Rgb): number {
+ const la = luminanceRgb(a);
+ const lb = luminanceRgb(b);
+ const [hi, lo] = la >= lb ? [la, lb] : [lb, la];
+ return (hi + 0.05) / (lo + 0.05);
+}
+
+/** Blend `colour` over white at `alpha` (0-1) → the resulting opaque rgb. */
+function overWhite(rgb: Rgb, alpha: number): Rgb {
+ return rgb.map((c) => c * alpha + 255 * (1 - alpha)) as Rgb;
+}
+
+/** Mix `rgb` toward black by `t` (0 = unchanged, 1 = black). */
+function towardBlack(rgb: Rgb, t: number): Rgb {
+ return rgb.map((c) => c * (1 - t)) as Rgb;
+}
+
+/**
+ * A dark, hue-preserving ink for `colour` that reads at ≥ 4.5:1 on `bg`. Starts
+ * from the colour itself (dark tags keep their exact hue) and darkens toward
+ * black only as far as legibility requires.
+ */
+function readableInk(rgb: Rgb, bg: Rgb): string {
+ for (let t = 0; t <= 1.0001; t += 0.05) {
+ const candidate = towardBlack(rgb, t);
+ if (contrast(candidate, bg) >= MIN_CONTRAST) return toHex(candidate);
+ }
+ return "#000000";
+}
+
+export interface ChipTokens {
+ backgroundColor: string;
+ borderColor: string;
+ color: string;
+ dot: string;
+}
+
+/**
+ * Inline tokens for a soft Tag chip: a light tint of the colour, a slightly
+ * stronger border, a colour dot, and dark hue-preserving ink guaranteed legible
+ * on the tint. One quiet, AA-safe vocabulary for every chip in the app.
+ */
+export function tagChipTokens(colour: string): ChipTokens {
+ const rgb = parseHex(colour) ?? parseHex(FALLBACK)!;
+ const tint = overWhite(rgb, 0.14);
+ const border = overWhite(rgb, 0.34);
+ return {
+ backgroundColor: toHex(tint),
+ borderColor: toHex(border),
+ color: readableInk(rgb, tint),
+ dot: toHex(rgb),
+ };
+}
diff --git a/src/lib/tags/model.test.ts b/src/lib/tags/model.test.ts
new file mode 100644
index 00000000..1b012fc0
--- /dev/null
+++ b/src/lib/tags/model.test.ts
@@ -0,0 +1,62 @@
+import { describe, expect, it } from "vitest";
+import { validateTagDraft } from "./model";
+
+describe("validateTagDraft", () => {
+ it("accepts a valid name + hex colour, trimming the name and lowercasing the hex", () => {
+ expect(validateTagDraft({ name: " Void ", colour: "#7C3AED" }, [])).toEqual({
+ ok: true,
+ tag: { name: "Void", colour: "#7c3aed" },
+ });
+ });
+
+ it("rejects a blank name (empty or whitespace-only)", () => {
+ expect(validateTagDraft({ name: " ", colour: "#7c3aed" }, [])).toEqual({
+ ok: false,
+ error: "Tag name is required",
+ });
+ });
+
+ it("rejects a name longer than 30 characters (after trimming)", () => {
+ const long = "a".repeat(31);
+ expect(validateTagDraft({ name: long, colour: "#7c3aed" }, [])).toEqual({
+ ok: false,
+ error: "Tag name must be 30 characters or fewer",
+ });
+ });
+
+ it("accepts a name of exactly 30 characters (boundary)", () => {
+ const name = "a".repeat(30);
+ expect(validateTagDraft({ name, colour: "#7c3aed" }, [])).toEqual({
+ ok: true,
+ tag: { name, colour: "#7c3aed" },
+ });
+ });
+
+ it("rejects a name that duplicates an existing one, case-insensitively", () => {
+ expect(
+ validateTagDraft({ name: " VOID ", colour: "#7c3aed" }, ["Void", "Phase 1"]),
+ ).toEqual({ ok: false, error: "A tag with this name already exists" });
+ });
+
+ it("accepts a name that clashes with no existing tag (edit excludes its own name)", () => {
+ // On edit the caller passes the OTHER tags' names, so keeping/recasing the
+ // tag's own name is allowed.
+ expect(
+ validateTagDraft({ name: "Void", colour: "#7c3aed" }, ["Phase 1"]),
+ ).toEqual({ ok: true, tag: { name: "Void", colour: "#7c3aed" } });
+ });
+
+ it("rejects a colour that is not a hex code", () => {
+ expect(validateTagDraft({ name: "Void", colour: "red" }, [])).toEqual({
+ ok: false,
+ error: "Colour must be a hex code like #7c3aed",
+ });
+ });
+
+ it("accepts a 3-digit hex shorthand, normalised to lowercase", () => {
+ expect(validateTagDraft({ name: "Void", colour: "#ABC" }, [])).toEqual({
+ ok: true,
+ tag: { name: "Void", colour: "#abc" },
+ });
+ });
+});
diff --git a/src/lib/tags/model.ts b/src/lib/tags/model.ts
new file mode 100644
index 00000000..49e8f39e
--- /dev/null
+++ b/src/lib/tags/model.ts
@@ -0,0 +1,43 @@
+/**
+ * Pure Tag domain logic — validation + normalisation for creating/editing a
+ * portfolio Tag (ADR-0013). Kept free of DB access so it unit-tests cleanly and
+ * is shared by the tag routes. The DB's case-insensitive unique index is the
+ * ultimate guard against duplicate names; this gives a friendly pre-check.
+ */
+
+export const MAX_TAG_NAME_LENGTH = 30;
+
+/** A hex colour: #rgb or #rrggbb (case-insensitive). */
+const HEX_COLOUR = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
+
+export interface TagDraft {
+ name: string;
+ colour: string;
+}
+
+export type TagValidation =
+ | { ok: true; tag: TagDraft }
+ | { ok: false; error: string };
+
+export function validateTagDraft(
+ input: TagDraft,
+ existingNames: string[],
+): TagValidation {
+ const name = input.name.trim();
+ if (name.length === 0) return { ok: false, error: "Tag name is required" };
+ if (name.length > MAX_TAG_NAME_LENGTH) {
+ return {
+ ok: false,
+ error: `Tag name must be ${MAX_TAG_NAME_LENGTH} characters or fewer`,
+ };
+ }
+ const lower = name.toLowerCase();
+ if (existingNames.some((existing) => existing.trim().toLowerCase() === lower)) {
+ return { ok: false, error: "A tag with this name already exists" };
+ }
+ const colour = input.colour.trim().toLowerCase();
+ if (!HEX_COLOUR.test(colour)) {
+ return { ok: false, error: "Colour must be a hex code like #7c3aed" };
+ }
+ return { ok: true, tag: { name, colour } };
+}
diff --git a/src/lib/tags/server.ts b/src/lib/tags/server.ts
new file mode 100644
index 00000000..c4b00183
--- /dev/null
+++ b/src/lib/tags/server.ts
@@ -0,0 +1,48 @@
+/**
+ * Server-side helpers shared by the tag routes: portfolio-role lookup and the
+ * write gate. Tags are portfolio-scoped; per ADR-0013 (Q11) any member with a
+ * write-capable role manages and assigns them, read members are view-only.
+ */
+import { db } from "@/app/db/db";
+import { portfolioUsers } from "@/app/db/schema/portfolio";
+import { user } from "@/app/db/schema/users";
+import { and, eq } from "drizzle-orm";
+
+/** Roles allowed to create/edit/delete/assign tags (read is view-only). */
+const WRITE_ROLES = new Set(["creator", "admin", "write"]);
+
+export async function getPortfolioRole(
+ portfolioId: bigint,
+ email: string,
+): Promise {
+ const rows = await db
+ .select({ role: portfolioUsers.role })
+ .from(portfolioUsers)
+ .innerJoin(user, eq(user.id, portfolioUsers.userId))
+ .where(
+ and(eq(portfolioUsers.portfolioId, portfolioId), eq(user.email, email)),
+ )
+ .limit(1);
+ return rows[0]?.role ?? null;
+}
+
+/** A member (any role) may read; only write-capable roles may mutate. */
+export function canReadTags(role: string | null): boolean {
+ return role != null;
+}
+
+export function canWriteTags(role: string | null): boolean {
+ return role != null && WRITE_ROLES.has(role);
+}
+
+/**
+ * True when `err` is a Postgres unique-violation (SQLSTATE 23505) — the
+ * case-insensitive tag-name index racing a concurrent create/rename. node-postgres
+ * surfaces the code on the thrown error (or its `.cause`). Everything else is a
+ * real failure the caller must not mask as a duplicate-name 409.
+ */
+export function isUniqueViolation(err: unknown): boolean {
+ const code = (err as { code?: unknown; cause?: { code?: unknown } })?.code
+ ?? (err as { cause?: { code?: unknown } })?.cause?.code;
+ return code === "23505";
+}