mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-07-12 13:28:55 +00:00
migration for materials columns on recommendation table
This commit is contained in:
parent
a2a5d7212a
commit
62b10ef808
4 changed files with 10795 additions and 3 deletions
6
src/app/db/migrations/0224_busy_nitro.sql
Normal file
6
src/app/db/migrations/0224_busy_nitro.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE "recommendation" ADD COLUMN "material_id" bigint;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation" ADD COLUMN "material_quantity" real;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation" ADD COLUMN "material_quantity_unit" "unit_quantity";--> statement-breakpoint
|
||||
ALTER TABLE "recommendation" ADD COLUMN "material_depth" real;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation" ADD CONSTRAINT "recommendation_material_id_material_id_fk" FOREIGN KEY ("material_id") REFERENCES "public"."material"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "idx_recommendation_material_id" ON "recommendation" USING btree ("material_id");
|
||||
10770
src/app/db/migrations/meta/0224_snapshot.json
Normal file
10770
src/app/db/migrations/meta/0224_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1562,6 +1562,13 @@
|
|||
"when": 1780647248894,
|
||||
"tag": "0223_recommendation_plan_id_backfill",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 224,
|
||||
"version": "7",
|
||||
"when": 1780653770494,
|
||||
"tag": "0224_busy_nitro",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -60,6 +60,9 @@ export const measureTypeEnum = pgEnum("measure_type", [
|
|||
"sealing_open_fireplace",
|
||||
]);
|
||||
|
||||
export const unitQuantity: [string, ...string[]] = ["m2", "part", "kwp"];
|
||||
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
|
||||
|
||||
export const recommendation = pgTable(
|
||||
"recommendation",
|
||||
{
|
||||
|
|
@ -70,6 +73,13 @@ export const recommendation = pgTable(
|
|||
planId: bigint("plan_id", { mode: "bigint" }).references(() => plan.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
materialId: bigint("material_id", { mode: "bigint" }).references(
|
||||
() => material.id,
|
||||
{ onDelete: "set null" }
|
||||
),
|
||||
materialQuantity: real("material_quantity"),
|
||||
materialQuantityUnit: unitQuantityEnum("material_quantity_unit"),
|
||||
materialDepth: real("material_depth"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
type: text("type").notNull(),
|
||||
measureType: text("measure_type"),
|
||||
|
|
@ -107,12 +117,11 @@ export const recommendation = pgTable(
|
|||
.where(
|
||||
sql`${table.default} = true AND ${table.alreadyInstalled} = false`,
|
||||
),
|
||||
|
||||
index("idx_recommendation_material_id").on(table.materialId),
|
||||
],
|
||||
);
|
||||
|
||||
export const unitQuantity: [string, ...string[]] = ["m2", "part", "kwp"];
|
||||
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
|
||||
|
||||
export const recommendationMaterials = pgTable(
|
||||
"recommendation_materials",
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue