mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
added schemas for materials, recommendations and recommendationMaterials
This commit is contained in:
parent
5373c0adfc
commit
5bef451fd0
2 changed files with 85 additions and 50 deletions
|
|
@ -1,56 +1,54 @@
|
|||
// TODO: Materials database should live in a different database
|
||||
import {
|
||||
bigserial,
|
||||
text,
|
||||
timestamp,
|
||||
pgTable,
|
||||
real,
|
||||
pgEnum,
|
||||
json,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
// import {
|
||||
// bigserial,
|
||||
// text,
|
||||
// timestamp,
|
||||
// pgTable,
|
||||
// real,
|
||||
// pgEnum,
|
||||
// json,
|
||||
// } from "drizzle-orm/pg-core";
|
||||
export const MaterialType: [string, ...string[]] = [
|
||||
"suspended_floor_insulation",
|
||||
"solid_floor_insulation",
|
||||
"external_wall_insulation",
|
||||
"internal_wall_insulation",
|
||||
];
|
||||
export const materialTypeEnum = pgEnum("type", MaterialType);
|
||||
|
||||
// export const MaterialType: [string, ...string[]] = [
|
||||
// "suspended_floor_insulation",
|
||||
// "solid_floor_insulation",
|
||||
// "external_wall_insulation",
|
||||
// "internal_wall_insulation",
|
||||
// ];
|
||||
// export const materialTypeEnum = pgEnum("type", MaterialType);
|
||||
export const DepthUnit: [string, ...string[]] = ["mm"];
|
||||
export const depthUnitEnum = pgEnum("depth_unit", DepthUnit);
|
||||
|
||||
// export const DepthUnit: [string, ...string[]] = ["mm"];
|
||||
// export const depthUnitEnum = pgEnum("depth_unit", DepthUnit);
|
||||
export const CostUnit: [string, ...string[]] = ["gbp_sq_meter"];
|
||||
export const costUnitEnum = pgEnum("cost_unit", CostUnit);
|
||||
|
||||
// export const CostUnit: [string, ...string[]] = ["gbp_sq_meter"];
|
||||
// export const costUnitEnum = pgEnum("cost_unit", CostUnit);
|
||||
export const RValueUnit: [string, ...string[]] = [
|
||||
"square_meter_kelvin_per_watt",
|
||||
];
|
||||
export const rValueUnitEnum = pgEnum("r_value_unit", RValueUnit);
|
||||
|
||||
// export const RValueUnit: [string, ...string[]] = [
|
||||
// "square_meter_kelvin_per_watt",
|
||||
// ];
|
||||
// export const rValueUnitEnum = pgEnum("r_value_unit", RValueUnit);
|
||||
export const ThermalConductivityUnit: [string, ...string[]] = [
|
||||
"watt_per_meter_kelvin",
|
||||
];
|
||||
export const thermalConductivityUnitEnum = pgEnum(
|
||||
"thermal_conductivity_unit",
|
||||
ThermalConductivityUnit
|
||||
);
|
||||
|
||||
// export const ThermalConductivityUnit: [string, ...string[]] = [
|
||||
// "watt_per_meter_kelvin",
|
||||
// ];
|
||||
// export const thermalConductivityUnitEnum = pgEnum(
|
||||
// "thermal_conductivity_unit",
|
||||
// ThermalConductivityUnit
|
||||
// );
|
||||
|
||||
// export const materials = pgTable("property", {
|
||||
// id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
// type: materialTypeEnum("type").notNull(),
|
||||
// description: text("description").notNull(),
|
||||
// depths: json("json").$type<number[]>(),
|
||||
// depth_unit: depthUnitEnum("depth_unit"),
|
||||
// cost: real("cost"),
|
||||
// costUnit: costUnitEnum("cost_unit"),
|
||||
// rValuePerMm: real("r_value_per_mm"),
|
||||
// rValueUnit: rValueUnitEnum("r_value_unit"),
|
||||
// thermalConductivity: real("thermal_conductivity"),
|
||||
// thermalConductivityUnit: thermalConductivityUnitEnum(
|
||||
// "thermal_conductivity_unit"
|
||||
// ),
|
||||
// link: text("link"),
|
||||
// createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
// });
|
||||
export const material = pgTable("material", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
type: materialTypeEnum("type").notNull(),
|
||||
description: text("description").notNull(),
|
||||
depths: json("json").$type<number[]>(),
|
||||
depth_unit: depthUnitEnum("depth_unit"),
|
||||
cost: real("cost"),
|
||||
costUnit: costUnitEnum("cost_unit"),
|
||||
rValuePerMm: real("r_value_per_mm"),
|
||||
rValueUnit: rValueUnitEnum("r_value_unit"),
|
||||
thermalConductivity: real("thermal_conductivity"),
|
||||
thermalConductivityUnit: thermalConductivityUnitEnum(
|
||||
"thermal_conductivity_unit"
|
||||
),
|
||||
link: text("link"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
import {
|
||||
bigserial,
|
||||
text,
|
||||
timestamp,
|
||||
pgTable,
|
||||
real,
|
||||
boolean,
|
||||
bigint,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { material } from "./materials";
|
||||
|
||||
export interface ComponentRecommendation {
|
||||
id: number;
|
||||
type: string;
|
||||
|
|
@ -13,3 +24,29 @@ export interface Recommendation {
|
|||
Ventilation?: ComponentRecommendation[];
|
||||
Floor?: ComponentRecommendation[];
|
||||
}
|
||||
|
||||
export const recommendation = pgTable("recommendation", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
type: text("type").notNull(),
|
||||
description: text("description").notNull(),
|
||||
estimatedCost: real("estimated_cost"),
|
||||
default: boolean("default").notNull(),
|
||||
startingUValue: real("new_u_value"),
|
||||
newUValue: real("new_u_value"),
|
||||
sapPoints: real("sap_points"),
|
||||
heatDemand: real("heat_demand"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const recommendationMaterials = pgTable("recommendation_materials", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
recommendationId: bigint("recommendation_id", {
|
||||
mode: "bigint",
|
||||
})
|
||||
.notNull()
|
||||
.references(() => recommendation.id),
|
||||
materialId: bigint("material_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => material.id),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue