mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Adding new fields to plans table
This commit is contained in:
parent
258c22fb3a
commit
92cbcd8130
8 changed files with 5257 additions and 2 deletions
|
|
@ -42,5 +42,9 @@ export async function GET(
|
|||
},
|
||||
});
|
||||
|
||||
if (!propertyMeta) {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
|
||||
return new NextResponse(JSON.stringify(propertyMeta, serializeBigInt));
|
||||
}
|
||||
|
|
|
|||
1
src/app/db/migrations/0081_nebulous_ezekiel.sql
Normal file
1
src/app/db/migrations/0081_nebulous_ezekiel.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE "plan" ADD COLUMN "name" text;
|
||||
20
src/app/db/migrations/0082_strong_gateway.sql
Normal file
20
src/app/db/migrations/0082_strong_gateway.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
ALTER TABLE "plan" ADD COLUMN "cost" real;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "total_work_hours" real;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "energy_savings" real;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "co2_equivalent_savings" real;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "energy_cost_savings" real;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "epc_breakdown_pre_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "epc_breakdown_post_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "number_of_properties" integer;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "n_units_to_retrofit" integer;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "co2_per_unit_pre_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "co2_per_unit_post_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "energy_bill_per_unit_pre_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "energy_bill_per_unit_post_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "energy_consumption_per_unit_pre_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "energy_consumption_per_unit_post_retrofit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "valuation_improvement_per_unit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "cost_per_unit" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "cost_per_co2_saved" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "cost_per_sap_point" text;--> statement-breakpoint
|
||||
ALTER TABLE "plan" ADD COLUMN "valuation_return_on_investment" text;
|
||||
2534
src/app/db/migrations/meta/0081_snapshot.json
Normal file
2534
src/app/db/migrations/meta/0081_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
2654
src/app/db/migrations/meta/0082_snapshot.json
Normal file
2654
src/app/db/migrations/meta/0082_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -568,6 +568,20 @@
|
|||
"when": 1722269231130,
|
||||
"tag": "0080_glossy_avengers",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 81,
|
||||
"version": "5",
|
||||
"when": 1722355117022,
|
||||
"tag": "0081_nebulous_ezekiel",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 82,
|
||||
"version": "5",
|
||||
"when": 1722356655029,
|
||||
"tag": "0082_strong_gateway",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import {
|
|||
boolean,
|
||||
bigint,
|
||||
pgEnum,
|
||||
integer,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { Material, material } from "./materials";
|
||||
import { InferModel } from "drizzle-orm";
|
||||
|
|
@ -62,6 +63,7 @@ export const recommendationMaterials = pgTable("recommendation_materials", {
|
|||
|
||||
export const plan = pgTable("plan", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
name: text("name"),
|
||||
portfolioId: bigint("portfolio_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => portfolio.id),
|
||||
|
|
@ -73,6 +75,32 @@ export const plan = pgTable("plan", {
|
|||
valuationIncreaseLowerBound: real("valuation_increase_lower_bound"),
|
||||
valuationIncreaseUpperBound: real("valuation_increase_upper_bound"),
|
||||
valuationIncreaseAverage: real("valuation_increase_average"),
|
||||
// Aggregations that were previously being stored against the portfolio, that are now being stored against the plan
|
||||
cost: real("cost"),
|
||||
totalWorkHours: real("total_work_hours"),
|
||||
energySavings: real("energy_savings"), // Unit is always kWh so we don't need to store unit
|
||||
co2EquivalentSavings: real("co2_equivalent_savings"), // Unit is always tonnes so we don't need to store unit
|
||||
energyCostSavings: real("energy_cost_savings"), // Unit is always £ so we don't need to store unit for the moment
|
||||
// Aggregates added for the summary tab
|
||||
epcBreakdownPreRetrofit: text("epc_breakdown_pre_retrofit"),
|
||||
epcBreakdownPostRetrofit: text("epc_breakdown_post_retrofit"),
|
||||
numberOfProperties: integer("number_of_properties"),
|
||||
nUnitsToRetrofit: integer("n_units_to_retrofit"),
|
||||
co2PerUnitPreRetrofit: text("co2_per_unit_pre_retrofit"),
|
||||
co2PerUnitPostRetrofit: text("co2_per_unit_post_retrofit"),
|
||||
energyBillPerUnitPreRetrofit: text("energy_bill_per_unit_pre_retrofit"),
|
||||
energyBillPerUnitPostRetrofit: text("energy_bill_per_unit_post_retrofit"),
|
||||
energyConsumptionPerUnitPreRetrofit: text(
|
||||
"energy_consumption_per_unit_pre_retrofit"
|
||||
),
|
||||
energyConsumptionPerUnitPostRetrofit: text(
|
||||
"energy_consumption_per_unit_post_retrofit"
|
||||
),
|
||||
valuationImprovementPerUnit: text("valuation_improvement_per_unit"),
|
||||
costPerUnit: text("cost_per_unit"),
|
||||
costPerCo2Saved: text("cost_per_co2_saved"),
|
||||
costPerSapPoint: text("cost_per_sap_point"),
|
||||
valuationReturnOnInvestment: text("valuation_return_on_investment"),
|
||||
});
|
||||
|
||||
export const planRecommendations = pgTable("plan_recommendations", {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es5",
|
||||
// "target": "ESNext",
|
||||
// "target": "es5",
|
||||
"target": "ESNext",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue