fix: Plugin migration runner + unified_search + marketplace migrations
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
Fixes 3 issues found by API integration tests: 1. migration_runner.py: Add GLOBAL TABLE exemption for tables without tenant_id - New _extract_global_table_names() method parses -- GLOBAL TABLE: comments - marketplace_listings is intentionally global (no tenant_id) 2. unified_search/migrations/0002_embeddings.sql: Remove companies table (does not exist), add DO $$ BEGIN END $$ blocks to check table existence before ALTER 3. marketplace/migrations/0001_initial.sql: Add -- GLOBAL TABLE: marketplace_listings comment
This commit is contained in:
@@ -1,27 +1,45 @@
|
||||
-- Unified Search: Embedding columns and HNSW indexes
|
||||
-- Note: These columns are also added by Alembic migration 0104.
|
||||
-- This migration is idempotent (IF NOT EXISTS) and skips non-existent tables.
|
||||
|
||||
-- Ensure pgvector extension is installed
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
|
||||
-- ─── Mails ───
|
||||
ALTER TABLE mails ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_mails_embedding ON mails USING hnsw(embedding vector_cosine_ops);
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'mails') THEN
|
||||
ALTER TABLE mails ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_mails_embedding ON mails USING hnsw(embedding vector_cosine_ops);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ─── Contacts ───
|
||||
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_contacts_embedding ON contacts USING hnsw(embedding vector_cosine_ops);
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'contacts') THEN
|
||||
ALTER TABLE contacts ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_contacts_embedding ON contacts USING hnsw(embedding vector_cosine_ops);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ─── Companies ───
|
||||
ALTER TABLE companies ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_companies_embedding ON companies USING hnsw(embedding vector_cosine_ops);
|
||||
|
||||
-- ─── Files (content_text already added in 0001) ───
|
||||
ALTER TABLE files ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_files_embedding ON files USING hnsw(embedding vector_cosine_ops);
|
||||
-- ─── Files ───
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'files') THEN
|
||||
ALTER TABLE files ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_files_embedding ON files USING hnsw(embedding vector_cosine_ops);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ─── Calendar Entries ───
|
||||
ALTER TABLE calendar_entries ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_cal_embedding ON calendar_entries USING hnsw(embedding vector_cosine_ops);
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'calendar_entries') THEN
|
||||
ALTER TABLE calendar_entries ADD COLUMN IF NOT EXISTS embedding vector(768);
|
||||
CREATE INDEX IF NOT EXISTS ix_cal_embedding ON calendar_entries USING hnsw(embedding vector_cosine_ops);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ─── Tags (shorter dimension for short text) ───
|
||||
ALTER TABLE tags ADD COLUMN IF NOT EXISTS embedding vector(384);
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'tags') THEN
|
||||
ALTER TABLE tags ADD COLUMN IF NOT EXISTS embedding vector(384);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
Reference in New Issue
Block a user