mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-07-12 13:28:55 +00:00
Add index on plan_recommendations.recommendation_id to Drizzle schema
Plan deletes cascade to recommendation rows, and each cascaded delete fires an FK check against plan_recommendations.recommendation_id. With ~26M rows and no index on that column the check seq-scans per row, making any plan deletion path time out. The index already exists on the live DB (created CONCURRENTLY on 2026-07-02 as idx_plan_recommendations_recommendation_id, 74s build); this brings the Drizzle schema in line so it stops drifting. No migration is included — generating/applying it is left as a human action, and it must reuse the existing index name (IF NOT EXISTS) so it no-ops against prod. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
767cb2af3f
commit
b49fbc4265
1 changed files with 7 additions and 0 deletions
|
|
@ -263,6 +263,13 @@ export const planRecommendations = pgTable(
|
|||
table.planId,
|
||||
table.recommendationId,
|
||||
),
|
||||
// Supports the FK check fired when `recommendation` rows are deleted
|
||||
// (cascaded from plan deletes); without it each delete seq-scans this
|
||||
// ~26M-row table. Already created on the live DB (CONCURRENTLY,
|
||||
// 2026-07-02) — the migration must match the existing index name.
|
||||
index("idx_plan_recommendations_recommendation_id").on(
|
||||
table.recommendationId,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue