From 09e9addfd0ce7218fd95f99d8adceb3da23a393c Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Tue, 27 Jan 2026 09:18:43 +0000 Subject: [PATCH] Define condition types and table with drizzle --- src/app/db/schema/condition/aspect_type.ts | 35 +++ .../db/schema/condition/asset_condition.ts | 32 +++ src/app/db/schema/condition/element.ts | 204 ++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 src/app/db/schema/condition/aspect_type.ts create mode 100644 src/app/db/schema/condition/asset_condition.ts create mode 100644 src/app/db/schema/condition/element.ts diff --git a/src/app/db/schema/condition/aspect_type.ts b/src/app/db/schema/condition/aspect_type.ts new file mode 100644 index 0000000..2ed494a --- /dev/null +++ b/src/app/db/schema/condition/aspect_type.ts @@ -0,0 +1,35 @@ +import { pgEnum } from "drizzle-orm/pg-core"; + +export const aspectType = pgEnum("aspect_type", [ + "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", +]); \ No newline at end of file diff --git a/src/app/db/schema/condition/asset_condition.ts b/src/app/db/schema/condition/asset_condition.ts new file mode 100644 index 0000000..2b860eb --- /dev/null +++ b/src/app/db/schema/condition/asset_condition.ts @@ -0,0 +1,32 @@ +import { + bigserial, + text, + date, + pgTable, + integer, + bigint, +} from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; +import { element } from "./element"; +import { aspectType } from "./aspect_type"; + + +export const assetCondition = pgTable("asset_condition", { + id: bigserial("id", { mode: "bigint" }).primaryKey(), + + uprn: bigint("uprn", { mode: "number" }).notNull(), + + element: element("element").notNull(), + aspectType: aspectType("aspect_type").notNull(), + + value: text("value"), + + quantity: integer("quantity"), + installDate: date("install_date"), + renewalYear: integer("renewal_year"), + + elementInstance: integer("element_instance"), + + sourceSystem: text("source_system"), + comments: text("comments"), +}); diff --git a/src/app/db/schema/condition/element.ts b/src/app/db/schema/condition/element.ts new file mode 100644 index 0000000..e2ad883 --- /dev/null +++ b/src/app/db/schema/condition/element.ts @@ -0,0 +1,204 @@ +import { pgEnum } from "drizzle-orm/pg-core"; + +export const element = pgEnum("element", [ + "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", +]);