diff --git a/supabase/migrations/20260705210000_retrieval_owner_filter_sentinel.sql b/supabase/migrations/20260705210000_retrieval_owner_filter_sentinel.sql index 9a973f440..7cdaf6ccf 100644 --- a/supabase/migrations/20260705210000_retrieval_owner_filter_sentinel.sql +++ b/supabase/migrations/20260705210000_retrieval_owner_filter_sentinel.sql @@ -528,6 +528,11 @@ as $$ limit match_count; $$; +-- The live/preview database may carry a match_document_chunks_text OUT signature +-- that differs from this batching rewrite (see 20260702170000 no-op note). +-- PostgreSQL rejects CREATE OR REPLACE when OUT columns change. +drop function if exists public.match_document_chunks_text(text, integer, uuid[], uuid); + create or replace function public.match_document_chunks_text( query_text text, match_count integer default 12, diff --git a/supabase/migrations/20260706120000_promote_remaining_indexed_documents_public.sql b/supabase/migrations/20260706120000_promote_remaining_indexed_documents_public.sql index 36edb7343..dfe343cea 100644 --- a/supabase/migrations/20260706120000_promote_remaining_indexed_documents_public.sql +++ b/supabase/migrations/20260706120000_promote_remaining_indexed_documents_public.sql @@ -42,12 +42,12 @@ from promoted_public_documents pd where dmc.document_id = pd.id; update public.document_table_facts dtf -set owner_id = null, updated_at = now() +set owner_id = null from promoted_public_documents pd where dtf.document_id = pd.id; update public.document_embedding_fields def -set owner_id = null, updated_at = now() +set owner_id = null from promoted_public_documents pd where def.document_id = pd.id; diff --git a/supabase/schema.sql b/supabase/schema.sql index 357ed9180..08b98df4c 100644 --- a/supabase/schema.sql +++ b/supabase/schema.sql @@ -2663,6 +2663,8 @@ as $$ limit match_count; $$; +drop function if exists public.match_document_chunks_text(text, integer, uuid[], uuid); + create or replace function public.match_document_chunks_text( query_text text, match_count integer default 12, diff --git a/tests/supabase-schema.test.ts b/tests/supabase-schema.test.ts index 5aeb3ce89..a721f4454 100644 --- a/tests/supabase-schema.test.ts +++ b/tests/supabase-schema.test.ts @@ -38,6 +38,10 @@ const phase7RetrievalPerformanceMigration = readFileSync( new URL("../supabase/migrations/20260626020000_phase7_retrieval_rpc_performance.sql", import.meta.url), "utf8", ).replace(/\s+/g, " "); +const retrievalOwnerFilterSentinelMigration = readFileSync( + new URL("../supabase/migrations/20260705210000_retrieval_owner_filter_sentinel.sql", import.meta.url), + "utf8", +).replace(/\s+/g, " "); const atomicReindexMigration = readFileSync( new URL("../supabase/migrations/20260628000000_atomic_reindex_generation_commit.sql", import.meta.url), "utf8", @@ -797,6 +801,12 @@ describe("Supabase Preview replay guards", () => { ); }); + it("drops match_document_chunks_text before retrieval owner sentinel rewrites it", () => { + expect(retrievalOwnerFilterSentinelMigration).toContain( + "drop function if exists public.match_document_chunks_text(text, integer, uuid[], uuid)", + ); + }); + it("guards pg_cron retention schedules for preview branches without cron.job", () => { for (const sql of [ragQueriesRetentionMigration, ragRetrievalLogsRetentionMigration]) { expect(sql).toContain("to_regnamespace('cron')");