fix pg_vector extension requires SUPERUSER, but not available on Huawei Cloud RDS (#24093)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
ba775a1c90
commit
16d1289a0a
2 changed files with 7 additions and 1 deletions
|
|
@ -9,6 +9,11 @@ class PGVectorConfig(BaseSettings):
|
||||||
Configuration settings for PGVector (PostgreSQL with vector extension)
|
Configuration settings for PGVector (PostgreSQL with vector extension)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
PGVECTOR_IS_OWNER: Optional[bool] = Field(
|
||||||
|
description="Whether the PGVector is the owner of the database",
|
||||||
|
default=True,
|
||||||
|
)
|
||||||
|
|
||||||
PGVECTOR_HOST: Optional[str] = Field(
|
PGVECTOR_HOST: Optional[str] = Field(
|
||||||
description="Hostname or IP address of the PostgreSQL server with PGVector extension (e.g., 'localhost')",
|
description="Hostname or IP address of the PostgreSQL server with PGVector extension (e.g., 'localhost')",
|
||||||
default=None,
|
default=None,
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,8 @@ class PGVector(BaseVector):
|
||||||
return
|
return
|
||||||
|
|
||||||
with self._get_cursor() as cur:
|
with self._get_cursor() as cur:
|
||||||
cur.execute("CREATE EXTENSION IF NOT EXISTS vector")
|
if dify_config.PGVECTOR_IS_OWNER:
|
||||||
|
cur.execute("CREATE EXTENSION IF NOT EXISTS vector")
|
||||||
cur.execute(SQL_CREATE_TABLE.format(table_name=self.table_name, dimension=dimension))
|
cur.execute(SQL_CREATE_TABLE.format(table_name=self.table_name, dimension=dimension))
|
||||||
# PG hnsw index only support 2000 dimension or less
|
# PG hnsw index only support 2000 dimension or less
|
||||||
# ref: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing
|
# ref: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue