poi-index: name pois PK explicitly (pois_pkey) for drift-free swap

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-07-12 22:55:49 +02:00
parent 96de8831cf
commit b1aa687c51
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
2 changed files with 4 additions and 2 deletions

View file

@ -52,7 +52,9 @@ export const pois = plannerSchema.table("pois", {
tags: jsonb("tags").$type<Record<string, string>>().notNull(),
importedAt: timestamp("imported_at", { withTimezone: true }).notNull().defaultNow(),
}, (t) => ({
pk: primaryKey({ columns: [t.osmType, t.osmId, t.category] }),
// Named explicitly so the import job's atomic swap can rename the staging
// table's PK to this exact name — keeping `db:push` drift-free post-swap.
pk: primaryKey({ name: "pois_pkey", columns: [t.osmType, t.osmId, t.category] }),
// GiST spatial index for the bbox intersection in the serving query.
geomIdx: index("pois_geom_idx").using("gist", t.geom),
// btree on category so `category = ANY($cats)` is index-driven.