added index on recommendations materials

This commit is contained in:
Khalim Conn-Kowlessar 2025-12-10 21:14:44 +00:00
parent fb342d0955
commit b248a1bee2
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[]] = [