Merge pull request #350 from Hestia-Homes/fix/plan-recommendations-rec-id-index

Add index on plan_recommendations.recommendation_id to Drizzle schema
This commit is contained in:
Jun-te Kim 2026-07-02 17:37:49 +01:00 committed by GitHub
commit f788c858c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11793 additions and 0 deletions

View file

@ -0,0 +1,4 @@
-- IF NOT EXISTS: this index was already created on the live DB on 2026-07-02
-- (CREATE INDEX CONCURRENTLY, outside the migration flow) to unblock a plan
-- cleanup; there this migration must no-op. Fresh environments build it here.
CREATE INDEX IF NOT EXISTS "idx_plan_recommendations_recommendation_id" ON "plan_recommendations" USING btree ("recommendation_id");

File diff suppressed because it is too large Load diff

View file

@ -1800,6 +1800,13 @@
"when": 1782999533851,
"tag": "0257_low_songbird",
"breakpoints": true
},
{
"idx": 258,
"version": "7",
"when": 1783009784235,
"tag": "0258_plan_recommendations_rec_id_index",
"breakpoints": true
}
]
}

View file

@ -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,
),
],
);