Skip to content

Commit 2226f29

Browse files
angelplusultrashatfield4timothycarambat
authored
Add PostgreSQL vector extension in createTableIfNotExists function (#4430)
* Add PostgreSQL vector extension in createTableIfNotExists function * move extension sql to function --------- Co-authored-by: shatfield4 <[email protected]> Co-authored-by: Timothy Carambat <[email protected]>
1 parent 3cb54fd commit 2226f29

File tree

1 file changed

+2
-0
lines changed
  • server/utils/vectorDbProviders/pgvector

1 file changed

+2
-0
lines changed

server/utils/vectorDbProviders/pgvector/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const PGVector = {
4444
"SELECT * FROM pg_catalog.pg_tables WHERE schemaname = 'public'",
4545
getEmbeddingTableSchemaSql:
4646
"SELECT column_name,data_type FROM information_schema.columns WHERE table_name = $1",
47+
createExtensionSql: "CREATE EXTENSION IF NOT EXISTS vector;",
4748
createTableSql: (dimensions) =>
4849
`CREATE TABLE IF NOT EXISTS "${PGVector.tableName()}" (id UUID PRIMARY KEY, namespace TEXT, embedding vector(${Number(dimensions)}), metadata JSONB, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)`,
4950

@@ -405,6 +406,7 @@ const PGVector = {
405406
*/
406407
createTableIfNotExists: async function (connection, dimensions = 384) {
407408
this.log(`Creating embedding table with ${dimensions} dimensions`);
409+
await connection.query(this.createExtensionSql);
408410
await connection.query(this.createTableSql(dimensions));
409411
return true;
410412
},

0 commit comments

Comments
 (0)