Skip to content

Commit

Permalink
Merge pull request #1743 from AIFlowML/fix/postgres-1561-vector-exten…
Browse files Browse the repository at this point in the history
…sion

fix(postgres): Handle vector extension creation properly (#1561)
  • Loading branch information
shakkernerd authored Jan 4, 2025
2 parents 73943a0 + 4240e75 commit 59fdddc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/adapter-postgres/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 $$
Expand Down

0 comments on commit 59fdddc

Please sign in to comment.