diff --git a/packages/adapter-postgres/schema.sql b/packages/adapter-postgres/schema.sql index 4a0f7c6f1d..2467c54028 100644 --- a/packages/adapter-postgres/schema.sql +++ b/packages/adapter-postgres/schema.sql @@ -10,10 +10,26 @@ -- DROP TABLE IF EXISTS rooms CASCADE; -- DROP TABLE IF EXISTS accounts CASCADE; +-- Create extensions schema first +CREATE SCHEMA IF NOT EXISTS extensions; + +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM pg_extension + WHERE extname = 'vector' + ) THEN + CREATE EXTENSION vector + SCHEMA extensions; + END IF; +END $$; -CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; +-- Add extensions schema to search path +SET search_path TO public, extensions; + -- Create a function to determine vector dimension CREATE OR REPLACE FUNCTION get_embedding_dimension() RETURNS INTEGER AS $$