mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 11:57:51 +01:00
Merge pull request #16606 from Rain6435/fix/azure-postgresql-pgvector-permissions
fix: resolve Azure PostgreSQL pgvector extension permission issue
This commit is contained in:
@@ -111,11 +111,35 @@ class PgvectorClient(VectorDBBase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Ensure the pgvector extension is available
|
# Ensure the pgvector extension is available
|
||||||
self.session.execute(text("CREATE EXTENSION IF NOT EXISTS vector;"))
|
# Use a conditional check to avoid permission issues on Azure PostgreSQL
|
||||||
|
self.session.execute(
|
||||||
|
text(
|
||||||
|
"""
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector') THEN
|
||||||
|
CREATE EXTENSION IF NOT EXISTS vector;
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if PGVECTOR_PGCRYPTO:
|
if PGVECTOR_PGCRYPTO:
|
||||||
# Ensure the pgcrypto extension is available for encryption
|
# Ensure the pgcrypto extension is available for encryption
|
||||||
self.session.execute(text("CREATE EXTENSION IF NOT EXISTS pgcrypto;"))
|
# Use a conditional check to avoid permission issues on Azure PostgreSQL
|
||||||
|
self.session.execute(
|
||||||
|
text(
|
||||||
|
"""
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'pgcrypto') THEN
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if not PGVECTOR_PGCRYPTO_KEY:
|
if not PGVECTOR_PGCRYPTO_KEY:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|||||||
Reference in New Issue
Block a user