From c766a0ed8a785452b40a8817492b33ff0a1e00e2 Mon Sep 17 00:00:00 2001 From: leoterry <754236623@qq.com> Date: Wed, 3 Jan 2024 14:19:08 +0800 Subject: [PATCH] fix: init pg error error: CREATE INDEX CONCURRENTLY cannot run inside a transaction block (#684) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: weifj <“weifj@tuyuansu.com.cn”> --- packages/service/common/vectorStore/pg/controller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/service/common/vectorStore/pg/controller.ts b/packages/service/common/vectorStore/pg/controller.ts index 018ee753f..a2a51cbac 100644 --- a/packages/service/common/vectorStore/pg/controller.ts +++ b/packages/service/common/vectorStore/pg/controller.ts @@ -22,7 +22,11 @@ export async function initPg() { data_id VARCHAR(50) NOT NULL, createTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); - CREATE INDEX CONCURRENTLY IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 32, ef_construction = 64); + `); + + await PgClient.query(` + CREATE INDEX CONCURRENTLY IF NOT EXISTS vector_index ON ${PgDatasetTableName} + USING hnsw (vector vector_ip_ops) WITH (m = 32, ef_construction = 64); `); console.log('init pg successful');