Skip to content

fix(db): migration 308 clobbered search_path, breaking 5 PostGIS/pg_trgm functions #442

Closed

Description

@thinkclay

Split from #440.

308_function_search_path.sql blanket-runs ALTER FUNCTION ... SET search_path = <own schema> over every function it owns, discarding whatever search_path the function was actually written with. It clobbered 37 functions. PostGIS lives in public, so any function resolving geometry / ST_* / similarity() unqualified now fails.

ERROR:  type "geometry" does not exist
LINE 9:     ST_X(j.geo::geometry) AS longitude,

Confirmed broken

Verified individually against a local DB. The other 32 clobbered functions fully-qualify their references and are unaffected.

Function Declared Now Impact
core.get_jobs_with_coords core, public core /workers/map job layer (the reported error)
core.get_organizations_with_coords core, public core /workers/map org layer
core.check_site_overlaps core, public core project site geo validation
core.validate_address_in_site core core project address validation
onet.search_occupations — onet similarity(), career-assessment occupation search

Fix

  1. New migration restoring a correct search_path on the 5 functions above.
  2. List both public and extensions — 309_move_extensions_to_extensions_schema.sql tries to move PostGIS to extensions and silently no-op'd locally (extension ownership), so the repair has to survive both states.
  3. Make 308 itself append to the existing search_path rather than overwrite, or it re-clobbers the fix on any re-run.

Acceptance

  • All 5 functions execute without error locally
  • /workers/map renders job and org pins
  • Career-assessment occupation search returns results
  • Re-running 308 does not reintroduce the breakage
  • Confirm whether 308 was applied to prod, and repair there if so

Activity

  1. thinkclay commented on Jul 30, 2026

    @thinkclay
    ContributorAuthor

    Fixed by #448 (merged). Migration 341 repairs search_path on all 5 broken functions, 308 no longer overwrites a declared search_path, and 341's verification block additionally caught the onet.search_occupations return-type mismatch.

    Verified: full supabase db reset applies the chain clean, 341 is idempotent, get_jobs_with_coords returns 11 pins and get_organizations_with_coords 9, occupation search ranks correctly.

    Follow-up filed as #468 — 10 functions from migrations 314–325 have no search_path at all, having been created after 308 ran.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions