Skip to content

fix(db): explicitly create search functions in public schema#67

Merged
zacharias-ona merged 1 commit into
mainfrom
fix/search-migration-explicit-schema
Apr 15, 2026
Merged

fix(db): explicitly create search functions in public schema#67
zacharias-ona merged 1 commit into
mainfrom
fix/search-migration-explicit-schema

Conversation

@zacharias-ona
Copy link
Copy Markdown
Collaborator

@zacharias-ona zacharias-ona commented Apr 15, 2026

Problem

PR #66 added public. to cross-function calls but the CREATE FUNCTION statements themselves had no schema prefix. On Supabase hosted projects the migration runner's search_path may not default to public, so the functions were created in the wrong schema while the qualified calls pointed at public.extract_text_from_lexical — which didn't exist there.

The Deploy Migrations workflow has now failed on 5 consecutive pushes to main, including the PR #66 merge itself.

Changes

1. Schema-qualify all DDL in the search migration

Prefix all statements with public.:

  • CREATE OR REPLACE FUNCTION public.extract_text_from_lexical
  • CREATE OR REPLACE FUNCTION public.page_search_vector
  • CREATE OR REPLACE FUNCTION public.search_pages
  • ALTER TABLE public.pages
  • CREATE INDEX ... ON public.pages
  • Generated column expression: public.page_search_vector(title, content)
  • Recursive self-calls: public.extract_text_from_lexical(child) / (content -> 'root')

The migration is now fully schema-explicit and independent of the session's search_path.

2. Replace dry-run with staging DB validation

supabase db push --dry-run only lists pending migrations — it doesn't execute SQL. This is why the original bug passed PR checks but failed on deploy.

The PR job now:

  1. Links to a staging Supabase project (SUPABASE_STAGING_PROJECT_ID)
  2. Runs supabase db reset --linked to wipe staging to a clean state
  3. Runs supabase db push to apply all migrations for real

This catches runtime SQL errors (missing functions, schema resolution, syntax in PL/pgSQL bodies) before merge.

Requires two new repository secrets:

  • SUPABASE_STAGING_PROJECT_ID — project ref for the staging Supabase instance
  • SUPABASE_STAGING_DB_PASSWORD — database password for the staging instance

A concurrency group serializes staging access so parallel PRs don't collide.

PR #66 qualified cross-function calls with public. but the CREATE
FUNCTION statements themselves had no schema prefix. On Supabase hosted
projects the migration runner's search_path may not default to public,
so the functions were created in the wrong schema while the qualified
calls pointed at public — where nothing existed.

Prefix all CREATE FUNCTION, ALTER TABLE, and CREATE INDEX statements
with public. so the migration is fully schema-explicit and independent
of the session's search_path.

Co-authored-by: Ona <no-reply@ona.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memo Ready Ready Preview, Comment Apr 15, 2026 2:26pm

Request Review

@zacharias-ona zacharias-ona merged commit 9c338d3 into main Apr 15, 2026
5 checks passed
@zacharias-ona zacharias-ona deleted the fix/search-migration-explicit-schema branch April 15, 2026 14:28
@zacharias-ona
Copy link
Copy Markdown
Collaborator Author

✅ UI verification skipped — no UI files changed (only supabase/migrations/).

@zacharias-ona
Copy link
Copy Markdown
Collaborator Author

✅ Post-merge verification passed.

Routes tested:

  • / — Landing page loaded, title present
  • /sign-in — Sign-in page loaded, email input present
  • /api/health — Health endpoint returned OK
  • /dashboard — Checked (no 5xx)
  • No console errors detected

Skipped: None — all routes exist and 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