From 62a31126a2531344fd658a262147a5fb75945b04 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 23 Apr 2026 16:48:24 +0000 Subject: [PATCH] remove accidental duplicate epcpropertydetails table --- src/app/db/schema/property.ts | 115 +--------------------------------- 1 file changed, 1 insertion(+), 114 deletions(-) diff --git a/src/app/db/schema/property.ts b/src/app/db/schema/property.ts index 2c367562..9ac06744 100644 --- a/src/app/db/schema/property.ts +++ b/src/app/db/schema/property.ts @@ -165,120 +165,7 @@ export const FeatureRating: [string, ...string[]] = [ "Poor", "Very poor", "N/A", -];export const propertyDetailsEpc = pgTable( - "property_details_epc", - { - id: bigserial("id", { mode: "bigint" }).primaryKey(), - propertyId: bigint("property_id", { mode: "bigint" }) - .notNull() - .references(() => property.id), - portfolioId: bigint("portfolio_id", { mode: "bigint" }) - .notNull() - .references(() => portfolio.id), - fullAddress: text("full_address"), - // Date the EPC was lodged - lodgementDate: timestamp("lodgement_date"), - isExpired: boolean("is_expired"), - totalFloorArea: real("total_floor_area"), - walls: text("walls"), - wallsRating: smallint("walls_rating"), - roof: text("roof"), - roofRating: smallint("roof_rating"), - floor: text("floor"), - floorRating: smallint("floor_rating"), - windows: text("windows"), - windowsRating: smallint("windows_rating"), - heating: text("heating"), - heatingRating: smallint("heating_rating"), - heatingControls: text("heating_controls"), - heatingControlsRating: smallint("heating_controls_rating"), - hotWater: text("hot_water"), - hotWaterRating: smallint("hot_water_rating"), - lighting: text("lighting"), - lightingRating: smallint("lighting_rating"), - mainfuel: text("mainfuel"), - ventilation: text("ventilation"), - solarPv: real("solar_pv"), - solarHotWater: boolean("solar_hot_water"), - windTurbine: smallint("wind_turbine"), - floorHeight: real("floor_height"), - numberHeatedRooms: integer("number_heated_rooms"), - heatLossCorridor: boolean("heat_loss_corridor"), - unheatedCorridorLength: real("unheated_corridor_length"), - numberOpenFireplaces: integer("number_of_open_fireplaces"), - numberExtensions: integer("number_of_extensions"), - numberStoreys: integer("number_of_storeys"), - mainsGas: boolean("mains_gas"), - energyTariff: text("energy_tariff"), - // This is heat demand - primaryEnergyConsumption: real("primary_energy_consumption"), - co2Emissions: real("co2_emissions"), - // Bad naming but currentEnergyDemand is the current kwh consumption - needs to be renamed - currentEnergyDemand: real("current_energy_demand"), - currentEnergyDemandHeatingHotwater: real( - "current_energy_demand_heating_hotwater", - ), - estimated: boolean("estimated").default(false), - // We indicate if the property has an overwritten SAP 05 EPC. I.e. there is a valid EPC, however it's a SAP 05 - // EPC which isn't particularly useful. This value is defaulted to False - sap05Overwritten: boolean("sap_05_overwritten").default(false), - // When we've overwritten a SAP 05 EPC, we store the SAP 05 score and rating here for reference - sap05Score: real("sap_05_score"), - sap05EpcRating: epcEnum("sap_05_epc_rating"), - // Include current estimates for energy bills, across the different types of energy - // These predictions are based on the EPC predicted consumptions + current energy prices - heatingEnergyCostCurrent: real("heating_cost_current"), - hotWaterEnergyCostCurrent: real("hot_water_cost_current"), - lightingEnergyCostCurrent: real("lighting_cost_current"), - appliancesEnergyCostCurrent: real("appliances_cost_current"), - gasStandingCharge: real("gas_standing_charge"), - electricityStandingCharge: real("electricity_standing_charge"), - - // When we have already installed measures, we will adjust the carbon, bills, kwh, heat demandto reflect this. We keep a record of - // 1) The adjustments - // 2) original values - // 3) a flag to indicate whether the values have been adjusted, for easily filtering - - // original values - we don't need bills because we don't actually adjust any of the originals we just subtract adjustments from current values - // TODO - deprecate - originalCo2Emissions: real("original_co2_emissions"), - originalPrimaryEnergyConsumption: real( - "original_primary_energy_consumption", - ), - originalCurrentEnergyDemand: real("original_current_energy_demand"), - originalCurrentEnergyDemandHeatingHotwater: real( - "original_current_energy_demand_heating_hotwater", - ), - - // adjustment quantities - TODO: deprecate - installedMeasuresCo2Adjustment: real("installed_measures_co2_adjustment"), - installedMeasuresEnergyDemandAdjustment: real( - "installed_measures_energy_demand_adjustment", - ), - installedMeasuresTotalEnergyBillAdjustment: real( - "installed_measures_total_energy_bill_adjustment", - ), - installedMeasuresHeatDemandAdjustment: real( - "installed_measures_heat_demand_adjustment", - ), - isEpcAdjustedForInstalledMeasures: boolean( - "is_epc_adjusted_for_installed_measures", - ).default(false), - - // Lodged values - lodgedCo2Emissions: real("lodged_co2_emissions"), - lodgedHeatDemand: real("lodged_heat_demand"), - hasBeenRemodelled: boolean("has_been_remodelled").default(false), - // additional fields - environment_impact_current: real("environment_impact_current"), - }, - (table) => [ - uniqueIndex("uq_property_details_epc_property_portfolio").on( - table.propertyId, - table.portfolioId, - ), - ], -); +]; export const FeatureRatingNumeric: [number, ...number[]] = [5, 4, 3, 2, 1];