mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Merge pull request #204 from Hestia-Homes/feature/rebaseline-db-changes
Some checks failed
Next.js Build Check / build (push) Has been cancelled
Some checks failed
Next.js Build Check / build (push) Has been cancelled
added new fields to db
This commit is contained in:
commit
23b1bf5ebc
8 changed files with 6163 additions and 589 deletions
5
src/app/db/migrations/0156_long_kitty_pryde.sql
Normal file
5
src/app/db/migrations/0156_long_kitty_pryde.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE "property" ADD COLUMN "lodged_sap_points" real;--> statement-breakpoint
|
||||
ALTER TABLE "property" ADD COLUMN "lodged_epc_rating" "epc";--> statement-breakpoint
|
||||
ALTER TABLE "property_details_epc" ADD COLUMN "lodged_co2_emissions" real;--> statement-breakpoint
|
||||
ALTER TABLE "property_details_epc" ADD COLUMN "lodged_heat_demand" real;--> statement-breakpoint
|
||||
ALTER TABLE "property_details_epc" ADD COLUMN "has_been_remodelled" boolean DEFAULT false;
|
||||
|
|
@ -3,12 +3,12 @@ CREATE TABLE "organisation" (
|
|||
"created_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
|
||||
"hubspot_company_id" text,
|
||||
"company_name" text
|
||||
"name" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "team" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"team_name" text NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"org_id" uuid NOT NULL,
|
||||
"created_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL
|
||||
File diff suppressed because it is too large
Load diff
5987
src/app/db/migrations/meta/0157_snapshot.json
Normal file
5987
src/app/db/migrations/meta/0157_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1097,8 +1097,15 @@
|
|||
{
|
||||
"idx": 156,
|
||||
"version": "7",
|
||||
"when": 1774015417999,
|
||||
"tag": "0156_light_shinko_yamashiro",
|
||||
"when": 1773838366481,
|
||||
"tag": "0156_long_kitty_pryde",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 157,
|
||||
"version": "7",
|
||||
"when": 1774268836524,
|
||||
"tag": "0157_cynical_serpent_society",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export const organisation = pgTable("organisation", {
|
|||
.defaultNow()
|
||||
.notNull(),
|
||||
hubspotCompanyId: text("hubspot_company_id"),
|
||||
companyName: text("company_name"),
|
||||
name: text("name"),
|
||||
});
|
||||
|
||||
export type Organisation = InferModel<typeof organisation, "select">;
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ export const Epc: [string, ...string[]] = ["A", "B", "C", "D", "E", "F", "G"];
|
|||
|
||||
export const propertyCreationStatusEnum = pgEnum(
|
||||
"creation_status",
|
||||
PropertyCreationStatus
|
||||
PropertyCreationStatus,
|
||||
);
|
||||
export const epcEnum = pgEnum("epc", Epc);
|
||||
export const propertyStatusEnum = pgEnum("status", PortfolioStatus);
|
||||
|
|
@ -137,18 +137,22 @@ export const property = pgTable(
|
|||
// 1) The number of points we've adjusted by
|
||||
// 2) a flag to indicate whether the SAP points have been adjusted, for easily filtering
|
||||
installedMeasuresSapPointAdjustment: real(
|
||||
"installed_measures_sap_point_adjustment"
|
||||
"installed_measures_sap_point_adjustment",
|
||||
),
|
||||
isSapPointsAdjustedForInstalledMeasures: boolean(
|
||||
"is_sap_points_adjusted_for_installed_measures"
|
||||
"is_sap_points_adjusted_for_installed_measures",
|
||||
).default(false),
|
||||
// To be deprecated
|
||||
originalSapPoints: real("original_sap_points"),
|
||||
// lodged data
|
||||
lodgedSapPoints: real("lodged_sap_points"),
|
||||
lodgedEpcRating: epcEnum("lodged_epc_rating"),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("uq_property_portfolio_uprn")
|
||||
.on(table.portfolioId, table.uprn)
|
||||
.where(sql`${table.uprn} IS NOT NULL`),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
export const FeatureRating: [string, ...string[]] = [
|
||||
|
|
@ -212,7 +216,7 @@ export const propertyDetailsEpc = pgTable(
|
|||
// 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"
|
||||
"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
|
||||
|
|
@ -236,36 +240,42 @@ export const propertyDetailsEpc = pgTable(
|
|||
// 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"
|
||||
"original_primary_energy_consumption",
|
||||
),
|
||||
originalCurrentEnergyDemand: real("original_current_energy_demand"),
|
||||
originalCurrentEnergyDemandHeatingHotwater: real(
|
||||
"original_current_energy_demand_heating_hotwater"
|
||||
"original_current_energy_demand_heating_hotwater",
|
||||
),
|
||||
|
||||
// adjustment quantities
|
||||
// adjustment quantities - TODO: deprecate
|
||||
installedMeasuresCo2Adjustment: real("installed_measures_co2_adjustment"),
|
||||
installedMeasuresEnergyDemandAdjustment: real(
|
||||
"installed_measures_energy_demand_adjustment"
|
||||
"installed_measures_energy_demand_adjustment",
|
||||
),
|
||||
installedMeasuresTotalEnergyBillAdjustment: real(
|
||||
"installed_measures_total_energy_bill_adjustment"
|
||||
"installed_measures_total_energy_bill_adjustment",
|
||||
),
|
||||
installedMeasuresHeatDemandAdjustment: real(
|
||||
"installed_measures_heat_demand_adjustment"
|
||||
"installed_measures_heat_demand_adjustment",
|
||||
),
|
||||
isEpcAdjustedForInstalledMeasures: boolean(
|
||||
"is_epc_adjusted_for_installed_measures"
|
||||
"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),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("uq_property_details_epc_property_portfolio").on(
|
||||
table.propertyId,
|
||||
table.portfolioId
|
||||
table.portfolioId,
|
||||
),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
export const propertyDetailsSpatial = pgTable(
|
||||
|
|
@ -281,7 +291,7 @@ export const propertyDetailsSpatial = pgTable(
|
|||
isListedBuilding: boolean("is_listed_building"),
|
||||
isHeritageBuilding: boolean("is_heritage_building"),
|
||||
},
|
||||
(table) => [uniqueIndex("uq_property_details_spatial_uprn").on(table.uprn)]
|
||||
(table) => [uniqueIndex("uq_property_details_spatial_uprn").on(table.uprn)],
|
||||
);
|
||||
|
||||
export const propertyDetailsMeter = pgTable("property_details_meter", {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ import { portfolio, roleEnum } from "./portfolio";
|
|||
|
||||
export const team = pgTable("team", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
teamName: text("team_name").notNull(),
|
||||
orgId: uuid("org_id").notNull().references(() => organisation.id),
|
||||
name: text("name").notNull(),
|
||||
orgId: uuid("org_id")
|
||||
.notNull()
|
||||
.references(() => organisation.id),
|
||||
createdAt: timestamp("created_at", { precision: 6, withTimezone: true })
|
||||
.defaultNow()
|
||||
.notNull(),
|
||||
|
|
@ -21,7 +23,9 @@ export const teamMembers = pgTable("team_members", {
|
|||
userId: bigint("user_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
teamId: uuid("team_id").notNull().references(() => team.id),
|
||||
teamId: uuid("team_id")
|
||||
.notNull()
|
||||
.references(() => team.id),
|
||||
createdAt: timestamp("created_at", { precision: 6, withTimezone: true })
|
||||
.defaultNow()
|
||||
.notNull(),
|
||||
|
|
@ -32,7 +36,9 @@ export const teamMembers = pgTable("team_members", {
|
|||
|
||||
export const teamPortfolioPermissions = pgTable("team_portfolio_permissions", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
teamId: uuid("team_id").notNull().references(() => team.id),
|
||||
teamId: uuid("team_id")
|
||||
.notNull()
|
||||
.references(() => team.id),
|
||||
portfolioId: bigint("portfolio_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => portfolio.id),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue