setting up propertyTargets table

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-31 15:05:46 +01:00
parent 7596fecd17
commit cf0b0acae4
5 changed files with 1532 additions and 0 deletions

View file

@ -0,0 +1 @@
ALTER TABLE "property" RENAME COLUMN "status" TO "creation_status";

View file

@ -0,0 +1,10 @@
ALTER TYPE "property_status" ADD VALUE 'scoping';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'assessment';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'tendering';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'project underway';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'completion; status: on track';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'completion; status: delayed';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'completion; status: at risk';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'completion; status: completed';--> statement-breakpoint
ALTER TYPE "property_status" ADD VALUE 'needs review';--> statement-breakpoint
ALTER TABLE "property" ADD COLUMN "status" "property_status";

View file

@ -0,0 +1,749 @@
{
"version": "5",
"dialect": "pg",
"id": "cbe4ccb7-95d6-4d68-953b-ad5d04fb1b11",
"prevId": "079698d6-54de-431f-b0ab-151e8d8f5024",
"tables": {
"portfolio": {
"name": "portfolio",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"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",
"primaryKey": false,
"notNull": true
},
"goal": {
"name": "goal",
"type": "goal",
"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
},
"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": {}
},
"portfolioUsers": {
"name": "portfolioUsers",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"portfolio_id": {
"name": "portfolio_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "role",
"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": {}
},
"property": {
"name": "property",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"portfolio_id": {
"name": "portfolio_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"creation_status": {
"name": "creation_status",
"type": "property_status",
"primaryKey": false,
"notNull": true
},
"uprn": {
"name": "uprn",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"address": {
"name": "address",
"type": "text",
"primaryKey": false,
"notNull": false
},
"postcode": {
"name": "postcode",
"type": "text",
"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
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"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
},
"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",
"primaryKey": false,
"notNull": false
},
"current_sap_points": {
"name": "current_sap_points",
"type": "real",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"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": {}
},
"property_details_epc": {
"name": "property_details_epc",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"property_id": {
"name": "property_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"portfolio_id": {
"name": "portfolio_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"full_address": {
"name": "full_address",
"type": "text",
"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": "feature_rating",
"primaryKey": false,
"notNull": false
},
"roof": {
"name": "roof",
"type": "text",
"primaryKey": false,
"notNull": false
},
"roof_rating": {
"name": "roof_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"floor": {
"name": "floor",
"type": "text",
"primaryKey": false,
"notNull": false
},
"floor_rating": {
"name": "floor_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"windows": {
"name": "windows",
"type": "text",
"primaryKey": false,
"notNull": false
},
"windows_rating": {
"name": "windows_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"heating": {
"name": "heating",
"type": "text",
"primaryKey": false,
"notNull": false
},
"heating_rating": {
"name": "heating_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"heating_contols": {
"name": "heating_contols",
"type": "text",
"primaryKey": false,
"notNull": false
},
"heating_contols_rating": {
"name": "heating_contols_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"hot_water": {
"name": "hot_water",
"type": "text",
"primaryKey": false,
"notNull": false
},
"hot_water_rating": {
"name": "hot_water_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"lighting": {
"name": "lighting",
"type": "text",
"primaryKey": false,
"notNull": false
},
"lighting_rating": {
"name": "lighting_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"ventilation": {
"name": "ventilation",
"type": "text",
"primaryKey": false,
"notNull": false
},
"solar_pv": {
"name": "solar_pv",
"type": "text",
"primaryKey": false,
"notNull": false
},
"solar_hot_water": {
"name": "solar_hot_water",
"type": "text",
"primaryKey": false,
"notNull": false
},
"wind_turbine": {
"name": "wind_turbine",
"type": "text",
"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
}
},
"indexes": {},
"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": {}
},
"property_details_meter": {
"name": "property_details_meter",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"uprn": {
"name": "uprn",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"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": {}
},
"user": {
"name": "user",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"firstName": {
"name": "firstName",
"type": "text",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"oauth_id": {
"name": "oauth_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"oauth_provider": {
"name": "oauth_provider",
"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": {}
}
},
"enums": {
"goal": {
"name": "goal",
"values": {
"Valuation Improvement": "Valuation Improvement",
"Increasing EPC": "Increasing EPC",
"Reducing CO2 emissions": "Reducing CO2 emissions",
"Energy Savings": "Energy Savings",
"None": "None"
}
},
"role": {
"name": "role",
"values": {
"creator": "creator",
"admin": "admin",
"read": "read",
"write": "write"
}
},
"status": {
"name": "status",
"values": {
"scoping": "scoping",
"assessment": "assessment",
"tendering": "tendering",
"project underway": "project underway",
"completion; status: on track": "completion; status: on track",
"completion; status: delayed": "completion; status: delayed",
"completion; status: at risk": "completion; status: at risk",
"completion; status: completed": "completion; status: completed",
"needs review": "needs review"
}
},
"epc": {
"name": "epc",
"values": {
"A": "A",
"B": "B",
"C": "C",
"D": "D",
"E": "E",
"F": "F",
"G": "G"
}
},
"feature_rating": {
"name": "feature_rating",
"values": {
"Very good": "Very good",
"Good": "Good",
"Poor": "Poor",
"Very poor": "Very poor",
"N/A": "N/A"
}
},
"property_status": {
"name": "property_status",
"values": {
"LOADING": "LOADING",
"READY": "READY",
"ERROR": "ERROR"
}
}
},
"schemas": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {
"\"property\".\"status\"": "\"property\".\"creation_status\""
}
}
}

View file

@ -0,0 +1,759 @@
{
"version": "5",
"dialect": "pg",
"id": "52af8085-b24e-4d3e-a904-fa532f0903e7",
"prevId": "cbe4ccb7-95d6-4d68-953b-ad5d04fb1b11",
"tables": {
"portfolio": {
"name": "portfolio",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"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",
"primaryKey": false,
"notNull": true
},
"goal": {
"name": "goal",
"type": "goal",
"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
},
"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": {}
},
"portfolioUsers": {
"name": "portfolioUsers",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"portfolio_id": {
"name": "portfolio_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "role",
"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": {}
},
"property": {
"name": "property",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"portfolio_id": {
"name": "portfolio_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"creation_status": {
"name": "creation_status",
"type": "property_status",
"primaryKey": false,
"notNull": true
},
"uprn": {
"name": "uprn",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "property_status",
"primaryKey": false,
"notNull": false
},
"address": {
"name": "address",
"type": "text",
"primaryKey": false,
"notNull": false
},
"postcode": {
"name": "postcode",
"type": "text",
"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
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"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
},
"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",
"primaryKey": false,
"notNull": false
},
"current_sap_points": {
"name": "current_sap_points",
"type": "real",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"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": {}
},
"property_details_epc": {
"name": "property_details_epc",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"property_id": {
"name": "property_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"portfolio_id": {
"name": "portfolio_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"full_address": {
"name": "full_address",
"type": "text",
"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": "feature_rating",
"primaryKey": false,
"notNull": false
},
"roof": {
"name": "roof",
"type": "text",
"primaryKey": false,
"notNull": false
},
"roof_rating": {
"name": "roof_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"floor": {
"name": "floor",
"type": "text",
"primaryKey": false,
"notNull": false
},
"floor_rating": {
"name": "floor_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"windows": {
"name": "windows",
"type": "text",
"primaryKey": false,
"notNull": false
},
"windows_rating": {
"name": "windows_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"heating": {
"name": "heating",
"type": "text",
"primaryKey": false,
"notNull": false
},
"heating_rating": {
"name": "heating_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"heating_contols": {
"name": "heating_contols",
"type": "text",
"primaryKey": false,
"notNull": false
},
"heating_contols_rating": {
"name": "heating_contols_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"hot_water": {
"name": "hot_water",
"type": "text",
"primaryKey": false,
"notNull": false
},
"hot_water_rating": {
"name": "hot_water_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"lighting": {
"name": "lighting",
"type": "text",
"primaryKey": false,
"notNull": false
},
"lighting_rating": {
"name": "lighting_rating",
"type": "feature_rating",
"primaryKey": false,
"notNull": false
},
"ventilation": {
"name": "ventilation",
"type": "text",
"primaryKey": false,
"notNull": false
},
"solar_pv": {
"name": "solar_pv",
"type": "text",
"primaryKey": false,
"notNull": false
},
"solar_hot_water": {
"name": "solar_hot_water",
"type": "text",
"primaryKey": false,
"notNull": false
},
"wind_turbine": {
"name": "wind_turbine",
"type": "text",
"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
}
},
"indexes": {},
"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": {}
},
"property_details_meter": {
"name": "property_details_meter",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"uprn": {
"name": "uprn",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"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": {}
},
"user": {
"name": "user",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"firstName": {
"name": "firstName",
"type": "text",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"oauth_id": {
"name": "oauth_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"oauth_provider": {
"name": "oauth_provider",
"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": {}
}
},
"enums": {
"goal": {
"name": "goal",
"values": {
"Valuation Improvement": "Valuation Improvement",
"Increasing EPC": "Increasing EPC",
"Reducing CO2 emissions": "Reducing CO2 emissions",
"Energy Savings": "Energy Savings",
"None": "None"
}
},
"role": {
"name": "role",
"values": {
"creator": "creator",
"admin": "admin",
"read": "read",
"write": "write"
}
},
"status": {
"name": "status",
"values": {
"scoping": "scoping",
"assessment": "assessment",
"tendering": "tendering",
"project underway": "project underway",
"completion; status: on track": "completion; status: on track",
"completion; status: delayed": "completion; status: delayed",
"completion; status: at risk": "completion; status: at risk",
"completion; status: completed": "completion; status: completed",
"needs review": "needs review"
}
},
"epc": {
"name": "epc",
"values": {
"A": "A",
"B": "B",
"C": "C",
"D": "D",
"E": "E",
"F": "F",
"G": "G"
}
},
"feature_rating": {
"name": "feature_rating",
"values": {
"Very good": "Very good",
"Good": "Good",
"Poor": "Poor",
"Very poor": "Very poor",
"N/A": "N/A"
}
},
"property_status": {
"name": "property_status",
"values": {
"scoping": "scoping",
"assessment": "assessment",
"tendering": "tendering",
"project underway": "project underway",
"completion; status: on track": "completion; status: on track",
"completion; status: delayed": "completion; status: delayed",
"completion; status: at risk": "completion; status: at risk",
"completion; status: completed": "completion; status: completed",
"needs review": "needs review"
}
}
},
"schemas": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}

View file

@ -163,4 +163,17 @@ export const propertyDetailsMeter = pgTable("property_details_meter", {
meterReadingGas: real("meter_reading_gas"),
});
export const propertyTargets = pgTable("property_targets", {
id: serial("id").primaryKey(),
propertyId: integer("property_id")
.notNull()
.references(() => property.id),
portfolioId: integer("portfolio_id")
.notNull()
.references(() => portfolio.id),
createdAt: timestamp("created_at").notNull(),
epc: epcEnum("epc"),
heatDemand: text("heat_demand"),
});
// TODO: We'll need a property details buildings materials for verisk data?