Skip to content

Repair geographic migration on populated databases - #100

Merged
ralyodio merged 1 commit into
mainfrom
repair/nichedb-geo-migration-20260913
Sep 13, 2026
Merged

Repair geographic migration on populated databases#100
ralyodio merged 1 commit into
mainfrom
repair/nichedb-geo-migration-20260913

Conversation

@ralyodio

@ralyodio ralyodio commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

The application crashes while applying migration 0023 to an existing database: PostgreSQL evaluates the geographic expression index with search_path restricted to pg_catalog, pg_temp, so ndb_geo_box cannot resolve its nested ndb_geo_shape call. The previous tests installed the index before inserting any rows, leaving this upgrade failure uncovered.

Capture the installation search path on the geographic functions. Repair 0023 because its transaction rolls back before it can be marked applied, and add forward migration 0024 for databases where 0023 already succeeded with an empty table. This preserves all existing data and the geographic index; no production schema workaround is needed.

Validation:

  • Reproduced the exact production error on a dedicated PostgreSQL 17 database with existing rows and in the new PGlite regression before the fix.
  • Applied every migration on PostgreSQL 17 with an existing item inserted before 0023; the row survives, geographic distance reads succeed, and REINDEX succeeds under the restricted search path.
  • 23 geographic tests pass, covering populated upgrades, nested helpers under the restricted path, and the forward repair for previously installed functions.
  • Full suite: 1,598 tests pass across 94 files; repository-wide Biome passes with existing warnings; git diff --check passes.

PostgreSQL behavior: https://www.postgresql.org/docs/17/sql-createindex.html

@ralyodio
ralyodio merged commit 2416cf1 into main Sep 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant