Skip to content

Commit c988a2f

Browse files
committed
fix(postgres): Handle vector extension creation properly (#1561)
- Add proper checks for vector extension existence - Create extensions schema if not exists - Add extensions schema to search path - Ensure idempotent schema creation
1 parent 76d4f42 commit c988a2f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/adapter-postgres/schema.sql

+17-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,26 @@
1010
-- DROP TABLE IF EXISTS rooms CASCADE;
1111
-- DROP TABLE IF EXISTS accounts CASCADE;
1212

13+
-- Create extensions schema first
14+
CREATE SCHEMA IF NOT EXISTS extensions;
15+
16+
DO $$
17+
BEGIN
18+
IF NOT EXISTS (
19+
SELECT 1
20+
FROM pg_extension
21+
WHERE extname = 'vector'
22+
) THEN
23+
CREATE EXTENSION vector
24+
SCHEMA extensions;
25+
END IF;
26+
END $$;
1327

14-
CREATE EXTENSION IF NOT EXISTS vector;
1528
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
1629

30+
-- Add extensions schema to search path
31+
SET search_path TO public, extensions;
32+
1733
-- Create a function to determine vector dimension
1834
CREATE OR REPLACE FUNCTION get_embedding_dimension()
1935
RETURNS INTEGER AS $$

0 commit comments

Comments
 (0)