diff --git a/supabase/drift-manifest.json b/supabase/drift-manifest.json index ca8b892b6..0291941b7 100644 --- a/supabase/drift-manifest.json +++ b/supabase/drift-manifest.json @@ -1,9 +1,9 @@ { - "generated_at": "2026-07-09T10:38:15.859Z", + "generated_at": "2026-07-11T02:45:10.714Z", "generator": "scripts/generate-drift-manifest.ts", "postgres_image": "supabase/postgres:17.6.1.127", - "schema_sha256": "3a60bf1561142aed58e45a1cf8a9605ccc715dd7358e154c4ad9879b82be4cd5", - "replay_seconds": 20, + "schema_sha256": "aa8a419ab55b4637b858df628aa250b714ab1acd715d4f7786bcf6ec71f5e218", + "replay_seconds": 22, "snapshot": { "views": [ { @@ -4263,12 +4263,6 @@ "table": "clinical_registry_record_sources", "def_hash": "aff03b1509bdec54ffc6611caf47b647" }, - { - "def": "CREATE INDEX clinical_registry_record_sources_record_idx ON public.clinical_registry_record_sources USING btree (record_id)", - "name": "clinical_registry_record_sources_record_idx", - "table": "clinical_registry_record_sources", - "def_hash": "ef53891aac4bf949c894e35187d71517" - }, { "def": "CREATE UNIQUE INDEX clinical_registry_records_owner_id_kind_slug_key ON public.clinical_registry_records USING btree (owner_id, kind, slug)", "name": "clinical_registry_records_owner_id_kind_slug_key", diff --git a/supabase/migrations/20260711000000_drop_redundant_registry_sources_record_index.sql b/supabase/migrations/20260711000000_drop_redundant_registry_sources_record_index.sql new file mode 100644 index 000000000..5eac8d26b --- /dev/null +++ b/supabase/migrations/20260711000000_drop_redundant_registry_sources_record_index.sql @@ -0,0 +1,19 @@ +-- Drop redundant index (supabase-postgres-best-practices review, 2026-07-11). +-- +-- clinical_registry_record_sources_record_idx (record_id) is a strict prefix of +-- the index backing the UNIQUE (record_id, document_id) constraint on +-- clinical_registry_record_sources. PostgreSQL can use the unique index's +-- leading column for every equality lookup on record_id, so the standalone +-- index adds write overhead with no read benefit. Same rationale as +-- 20260702110000_drop_redundant_indexes.sql. +-- +-- clinical_registry_record_sources_document_idx stays: document_id is not a +-- leading column of any other index and backs the documents ON DELETE CASCADE. +-- +-- NOTE: DROP INDEX CONCURRENTLY cannot run inside a transaction block, and +-- Supabase migrations run in one. The table is small (curated registry links), +-- so a plain DROP INDEX is fine. For zero-impact removal run manually outside +-- a transaction: +-- DROP INDEX CONCURRENTLY IF EXISTS public.clinical_registry_record_sources_record_idx; + +drop index if exists public.clinical_registry_record_sources_record_idx; diff --git a/supabase/schema.sql b/supabase/schema.sql index a95337bc1..40af81afa 100644 --- a/supabase/schema.sql +++ b/supabase/schema.sql @@ -4945,8 +4945,9 @@ create table if not exists public.clinical_registry_record_sources ( create index if not exists clinical_registry_records_owner_kind_idx on public.clinical_registry_records(owner_id, kind, title); -create index if not exists clinical_registry_record_sources_record_idx - on public.clinical_registry_record_sources(record_id); +-- No standalone record_id index: the unique (record_id, document_id) index's +-- leading column serves record_id lookups (20260711000000 dropped the redundant +-- clinical_registry_record_sources_record_idx). create index if not exists clinical_registry_record_sources_document_idx on public.clinical_registry_record_sources(document_id);