migrating data

This commit is contained in:
Khalim Conn-Kowlessar 2025-08-21 15:17:27 +00:00
parent 70e4c7630e
commit ad557efed0
3 changed files with 43 additions and 3 deletions

View file

@ -743,6 +743,41 @@
"when": 1755275440983,
"tag": "0105_third_husk",
"breakpoints": true
},
{
"idx": 106,
"version": "7",
"when": 1755710562749,
"tag": "0106_damp_tombstone",
"breakpoints": true
},
{
"idx": 107,
"version": "7",
"when": 1755713160403,
"tag": "0107_omniscient_molly_hayes",
"breakpoints": true
},
{
"idx": 108,
"version": "7",
"when": 1755714878033,
"tag": "0108_mighty_outlaw_kid",
"breakpoints": true
},
{
"idx": 109,
"version": "7",
"when": 1755715023523,
"tag": "0109_flashy_jane_foster",
"breakpoints": true
},
{
"idx": 110,
"version": "7",
"when": 1755789401931,
"tag": "0110_colossal_hulk",
"breakpoints": true
}
]
}

View file

@ -14,6 +14,7 @@ import {
import { Material, material } from "./materials";
import { InferModel } from "drizzle-orm";
import { z } from "zod";
import { readlink } from "fs";
export const recommendation = pgTable("recommendation", {
id: bigserial("id", { mode: "bigint" }).primaryKey(),
@ -25,6 +26,7 @@ export const recommendation = pgTable("recommendation", {
measureType: text("measure_type"),
description: text("description").notNull(),
estimatedCost: real("estimated_cost"),
constingencyCost: real("contingency_cost"),
// default will indicate whether a mtaterial is currently being used in a recommendation and we will use this boolean to switch
// between materials in the UI and switch off all materials entirely
default: boolean("default").notNull(),
@ -43,7 +45,7 @@ export const recommendation = pgTable("recommendation", {
alreadyInstalled: boolean("already_installed").default(false),
});
export const unitQuantity: [string, ...string[]] = ["m2", "part"];
export const unitQuantity: [string, ...string[]] = ["m2", "part", "kwp"];
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
export const recommendationMaterials = pgTable("recommendation_materials", {
@ -58,8 +60,8 @@ export const recommendationMaterials = pgTable("recommendation_materials", {
.references(() => material.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
depth: real("depth"),
quantity: real("quantity").notNull(),
quantityUnit: unitQuantityEnum("quantity_unit").notNull(),
quantity: real("quantity"),
quantityUnit: unitQuantityEnum("quantity_unit"),
estimatedCost: real("estimated_cost").notNull(),
});
@ -121,6 +123,8 @@ export const scenario = pgTable("scenario", {
isDefault: boolean("is_default").notNull(),
// Aggregations that were previously being stored against the portfolio, that are now being stored against the scenario
cost: real("cost"),
contingency: real("contingency"),
funding: real("funding"),
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

View file

@ -70,3 +70,4 @@ export default async function DocumentsPage(
</>
);
}