mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Adding quantity, quantity_unit and estimated_cost to recommendationsMaterial table
This commit is contained in:
parent
788aac7b83
commit
495fbd05f6
6 changed files with 1332 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
"use client";
|
||||
import type {
|
||||
import {
|
||||
Recommendation,
|
||||
RecommendationType,
|
||||
} from "@/app/db/schema/recommendations";
|
||||
|
|
|
|||
9
src/app/db/migrations/0036_real_stryfe.sql
Normal file
9
src/app/db/migrations/0036_real_stryfe.sql
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
DO $$ BEGIN
|
||||
CREATE TYPE "unit_quantity" AS ENUM('meters_squared');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "recommendation_materials" ADD COLUMN "quantity" real NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation_materials" ADD COLUMN "quantity_unit" "unit_quantity" NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation_materials" ADD COLUMN "estimated_cost" real NOT NULL;
|
||||
1296
src/app/db/migrations/meta/0036_snapshot.json
Normal file
1296
src/app/db/migrations/meta/0036_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -253,6 +253,13 @@
|
|||
"when": 1692183485471,
|
||||
"tag": "0035_perfect_tenebrous",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 36,
|
||||
"version": "5",
|
||||
"when": 1692623295104,
|
||||
"tag": "0036_real_stryfe",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
real,
|
||||
boolean,
|
||||
bigint,
|
||||
pgEnum,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { material } from "./materials";
|
||||
import { InferModel, relations } from "drizzle-orm";
|
||||
|
|
@ -36,6 +37,9 @@ export const recommendation = pgTable("recommendation", {
|
|||
totalWorkHours: real("total_work_hours"),
|
||||
});
|
||||
|
||||
export const unitQuantity: [string, ...string[]] = ["meters_squared"];
|
||||
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
|
||||
|
||||
export const recommendationMaterials = pgTable("recommendation_materials", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
recommendationId: bigint("recommendation_id", {
|
||||
|
|
@ -48,6 +52,9 @@ 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(),
|
||||
estimatedCost: real("estimated_cost").notNull(),
|
||||
});
|
||||
|
||||
export const plan = pgTable("plan", {
|
||||
|
|
|
|||
|
|
@ -50,3 +50,15 @@ export async function getProperties(
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getPortfolioPlan(portfolioId: string) {
|
||||
// To do this we need to do the following:
|
||||
// 1. For the portfolioId, get all of the default plans. This can be done from the plan table
|
||||
// 2. For the plans, get the recommendations. This can be done from the planRecommendation table
|
||||
// 3. For the recommendations get the materials, the quantity and the cost.
|
||||
// 4. For the materials, get the type of material
|
||||
// I need to make the following updates:
|
||||
// 1) Add quanitity to the recommendationMaterials table
|
||||
// 2) Add estimatedCost to the recommendationMaterials table. We want the cost here to be the cost associated to
|
||||
// the material type
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue