mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
rebuilt database
This commit is contained in:
parent
cf5761fd19
commit
beb6ccdabe
6 changed files with 1265 additions and 2 deletions
10
src/app/db/migrations/0017_fixed_warlock.sql
Normal file
10
src/app/db/migrations/0017_fixed_warlock.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
DO $$ BEGIN
|
||||
CREATE TYPE "creation_status" AS ENUM('LOADING', 'READY', 'ERROR');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE "property" CASCADE;--> statement-breakpoint
|
||||
DROP TABLE "property_details_epc";--> statement-breakpoint
|
||||
DROP TABLE "property_details_meter";--> statement-breakpoint
|
||||
DROP TABLE "property_targets";
|
||||
112
src/app/db/migrations/0018_majestic_thaddeus_ross.sql
Normal file
112
src/app/db/migrations/0018_majestic_thaddeus_ross.sql
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
CREATE TABLE IF NOT EXISTS "property" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"portfolio_id" integer NOT NULL,
|
||||
"creation_status" "creation_status" NOT NULL,
|
||||
"uprn" integer,
|
||||
"building_reference_number" integer,
|
||||
"status" "status",
|
||||
"address" text,
|
||||
"postcode" text,
|
||||
"has_pre_condition_report" boolean,
|
||||
"has_recommendations" boolean,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp DEFAULT now() NOT NULL,
|
||||
"property_type" text,
|
||||
"built_form" text,
|
||||
"local_authority" text,
|
||||
"constituency" text,
|
||||
"number_of_rooms" integer,
|
||||
"year_built" text,
|
||||
"tenure" text,
|
||||
"current_epc_rating" "epc",
|
||||
"current_sap_points" real
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "property_details_epc" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"property_id" integer NOT NULL,
|
||||
"portfolio_id" integer NOT NULL,
|
||||
"full_address" text,
|
||||
"total_floor_area" real,
|
||||
"walls" text,
|
||||
"walls_rating" smallint,
|
||||
"roof" text,
|
||||
"roof_rating" smallint,
|
||||
"floor" text,
|
||||
"floor_rating" smallint,
|
||||
"windows" text,
|
||||
"windows_rating" smallint,
|
||||
"heating" text,
|
||||
"heating_rating" smallint,
|
||||
"heating_contols" text,
|
||||
"heating_contols_rating" smallint,
|
||||
"hot_water" text,
|
||||
"hot_water_rating" smallint,
|
||||
"lighting" text,
|
||||
"lighting_rating" smallint,
|
||||
"mainfuel" text,
|
||||
"ventilation" text,
|
||||
"solar_pv" real,
|
||||
"solar_hot_water" boolean,
|
||||
"wind_turbine" smallint,
|
||||
"floor_height" real,
|
||||
"number_heated_rooms" integer,
|
||||
"heat_loss_corridor" boolean,
|
||||
"unheated_corridor_length" real,
|
||||
"number_of_open_fireplaces" integer,
|
||||
"number_of_extensions" integer,
|
||||
"number_of_storeys" integer,
|
||||
"mains_gas" boolean,
|
||||
"energy_tariff" text,
|
||||
"primary_energy_consumption" real,
|
||||
"co2_emissions" real
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "property_details_meter" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"uprn" integer NOT NULL,
|
||||
"energy_supplier" text,
|
||||
"gas_supplier" text,
|
||||
"meter_reading_total" real,
|
||||
"meter_reading_electricity" real,
|
||||
"meter_reading_gas" real
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "property_targets" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"property_id" integer NOT NULL,
|
||||
"portfolio_id" integer NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"epc" "epc",
|
||||
"heat_demand" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "property" ADD CONSTRAINT "property_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "portfolio"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "property_details_epc" ADD CONSTRAINT "property_details_epc_property_id_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "property"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "property_details_epc" ADD CONSTRAINT "property_details_epc_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "portfolio"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "property_targets" ADD CONSTRAINT "property_targets_property_id_property_id_fk" FOREIGN KEY ("property_id") REFERENCES "property"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "property_targets" ADD CONSTRAINT "property_targets_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "portfolio"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
297
src/app/db/migrations/meta/0017_snapshot.json
Normal file
297
src/app/db/migrations/meta/0017_snapshot.json
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
{
|
||||
"version": "5",
|
||||
"dialect": "pg",
|
||||
"id": "7fe62fb1-7270-4a1b-8f2a-582b1efdc6c9",
|
||||
"prevId": "6c36dd91-3c26-4c47-882f-c38ba4ccd275",
|
||||
"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": {}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"creation_status": {
|
||||
"name": "creation_status",
|
||||
"values": {
|
||||
"LOADING": "LOADING",
|
||||
"READY": "READY",
|
||||
"ERROR": "ERROR"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schemas": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
}
|
||||
}
|
||||
830
src/app/db/migrations/meta/0018_snapshot.json
Normal file
830
src/app/db/migrations/meta/0018_snapshot.json
Normal file
|
|
@ -0,0 +1,830 @@
|
|||
{
|
||||
"version": "5",
|
||||
"dialect": "pg",
|
||||
"id": "35b1337c-37e3-4e94-8c5e-075d64ee4d41",
|
||||
"prevId": "7fe62fb1-7270-4a1b-8f2a-582b1efdc6c9",
|
||||
"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": "creation_status",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"uprn": {
|
||||
"name": "uprn",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"building_reference_number": {
|
||||
"name": "building_reference_number",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "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,
|
||||
"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",
|
||||
"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": "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_contols": {
|
||||
"name": "heating_contols",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"heating_contols_rating": {
|
||||
"name": "heating_contols_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
|
||||
}
|
||||
},
|
||||
"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": {}
|
||||
},
|
||||
"property_targets": {
|
||||
"name": "property_targets",
|
||||
"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
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"epc": {
|
||||
"name": "epc",
|
||||
"type": "epc",
|
||||
"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": {}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"creation_status": {
|
||||
"name": "creation_status",
|
||||
"values": {
|
||||
"LOADING": "LOADING",
|
||||
"READY": "READY",
|
||||
"ERROR": "ERROR"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schemas": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +120,20 @@
|
|||
"when": 1690898325085,
|
||||
"tag": "0016_condemned_rogue",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 17,
|
||||
"version": "5",
|
||||
"when": 1690899825925,
|
||||
"tag": "0017_fixed_warlock",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 18,
|
||||
"version": "5",
|
||||
"when": 1690899900262,
|
||||
"tag": "0018_majestic_thaddeus_ross",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -70,11 +70,11 @@ export const PropertyCreationStatus: [string, ...string[]] = [
|
|||
export const Epc: [string, ...string[]] = ["A", "B", "C", "D", "E", "F", "G"];
|
||||
|
||||
export const propertyCreationStatusEnum = pgEnum(
|
||||
"property_status",
|
||||
"creation_status",
|
||||
PropertyCreationStatus
|
||||
);
|
||||
export const epcEnum = pgEnum("epc", Epc);
|
||||
export const propertyStatusEnum = pgEnum("property_status", PortfolioStatus);
|
||||
export const propertyStatusEnum = pgEnum("status", PortfolioStatus);
|
||||
|
||||
export const property = pgTable("property", {
|
||||
id: serial("id").primaryKey(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue