Merge pull request #149 from Hestia-Homes/new-reporting

added index on recommendations materials
This commit is contained in:
KhalimCK 2025-12-11 05:16:37 +08:00 committed by GitHub
commit 12edb94247
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4859 additions and 16 deletions

View file

@ -0,0 +1 @@
CREATE INDEX "recommendation_materials_recommendation_id_idx" ON "recommendation_materials" USING btree ("recommendation_id");

File diff suppressed because it is too large Load diff

View file

@ -960,6 +960,13 @@
"when": 1765397663012,
"tag": "0136_boring_charles_xavier",
"breakpoints": true
},
{
"idx": 137,
"version": "7",
"when": 1765400667595,
"tag": "0137_shallow_speedball",
"breakpoints": true
}
]
}

View file

@ -52,22 +52,30 @@ export const recommendation = pgTable(
export const unitQuantity: [string, ...string[]] = ["m2", "part", "kwp"];
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
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(),
depth: real("depth"),
quantity: real("quantity"),
quantityUnit: unitQuantityEnum("quantity_unit"),
estimatedCost: real("estimated_cost").notNull(),
});
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(),
depth: real("depth"),
quantity: real("quantity"),
quantityUnit: unitQuantityEnum("quantity_unit"),
estimatedCost: real("estimated_cost").notNull(),
},
(table) => [
index("recommendation_materials_recommendation_id_idx").on(
table.recommendationId
),
]
);
// We create a plan type, for common plan types that we produce for clients
export const PlanType: [string, ...string[]] = [