mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
fix(backend/db): extract schema dynamically from DATABASE_URL for search_path
- Parse schema parameter from DATABASE_URL instead of hardcoding 'platform'
- Use extracted schema in search_path: f'-c search_path={db_schema},public'
- Defaults to 'platform' if schema parameter not found
- Makes search_path configuration dynamic based on DATABASE_URL
This commit is contained in:
@@ -39,9 +39,13 @@ if POOL_TIMEOUT:
|
||||
DATABASE_URL = add_param(DATABASE_URL, "pool_timeout", POOL_TIMEOUT)
|
||||
|
||||
# Add public schema to search_path for pgvector type access
|
||||
# The vector extension is in public schema, but search_path is set to platform only via schema parameter
|
||||
# The vector extension is in public schema, but search_path is determined by schema parameter
|
||||
# Extract the schema from DATABASE_URL or default to 'platform'
|
||||
parsed_url = urlparse(DATABASE_URL)
|
||||
url_params = dict(parse_qsl(parsed_url.query))
|
||||
db_schema = url_params.get("schema", "platform")
|
||||
# This allows using ::vector without schema qualification
|
||||
DATABASE_URL = add_param(DATABASE_URL, "options", "-c search_path=platform,public")
|
||||
DATABASE_URL = add_param(DATABASE_URL, "options", f"-c search_path={db_schema},public")
|
||||
|
||||
HTTP_TIMEOUT = int(POOL_TIMEOUT) if POOL_TIMEOUT else None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user