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, "when": 1765397663012,
"tag": "0136_boring_charles_xavier", "tag": "0136_boring_charles_xavier",
"breakpoints": true "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 unitQuantity: [string, ...string[]] = ["m2", "part", "kwp"];
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity); export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
export const recommendationMaterials = pgTable("recommendation_materials", { export const recommendationMaterials = pgTable(
id: bigserial("id", { mode: "bigint" }).primaryKey(), "recommendation_materials",
recommendationId: bigint("recommendation_id", { {
mode: "bigint", id: bigserial("id", { mode: "bigint" }).primaryKey(),
}) recommendationId: bigint("recommendation_id", {
.notNull() mode: "bigint",
.references(() => recommendation.id), })
materialId: bigint("material_id", { mode: "bigint" }) .notNull()
.notNull() .references(() => recommendation.id),
.references(() => material.id), materialId: bigint("material_id", { mode: "bigint" })
createdAt: timestamp("created_at").notNull().defaultNow(), .notNull()
depth: real("depth"), .references(() => material.id),
quantity: real("quantity"), createdAt: timestamp("created_at").notNull().defaultNow(),
quantityUnit: unitQuantityEnum("quantity_unit"), depth: real("depth"),
estimatedCost: real("estimated_cost").notNull(), 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 // We create a plan type, for common plan types that we produce for clients
export const PlanType: [string, ...string[]] = [ export const PlanType: [string, ...string[]] = [