Skip to content

✨ feat: add PGVECTOR_CREATE_EXTENSION env to support managed Postgres - #284

Merged
danny-avila merged 3 commits into
mainfrom
claude/wizardly-kapitsa-630382
Apr 23, 2026
Merged

danny-avila merged 3 commits into
mainfrom
claude/wizardly-kapitsa-630382

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new PGVECTOR_CREATE_EXTENSION env var (default True — back-compatible) that, when set to False, skips the CREATE EXTENSION IF NOT EXISTS vector call langchain's PGVector runs on startup.
  • Plumbs a create_extension argument through get_vector_store into ExtendedPgVector/AsyncPgVector.
  • Documents the new env var in the README.

Fixes a startup crash on managed Postgres (RDS, Azure Database for PostgreSQL, Cloud SQL, etc.) where the application user is not a superuser but the vector extension has already been pre-installed out-of-band. Without this flag, the container loops on psycopg2.errors.InsufficientPrivilege: permission denied to create extension "vector".

Closes #275, closes #99.

Test plan

  • tests/services/test_vector_store_factory.py — added test_get_vector_store_defaults_create_extension_true and test_get_vector_store_propagates_create_extension_false covering both sync and async modes.
  • Manual: deploy with PGVECTOR_CREATE_EXTENSION=False against a Postgres instance where the app user is not a superuser and vector is pre-installed — container should start cleanly.
  • Manual: deploy without the env var set — behavior should be unchanged (extension creation attempted as today).

🤖 Generated with Claude Code

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Plumbs a create_extension parameter through get_vector_store into
ExtendedPgVector/AsyncPgVector so callers can opt out of the
CREATE EXTENSION IF NOT EXISTS vector call that langchain's PGVector
runs on __post_init__.
Fixes startup crash on managed Postgres (RDS, Azure Database for
PostgreSQL, etc.) where the app user lacks superuser privileges and
the vector extension is already pre-installed out-of-band. Default
stays True to preserve existing behavior.

Closes #275, closes #99
@danny-avila
danny-avila force-pushed the claude/wizardly-kapitsa-630382 branch from f30b680 to d9b4f77 Compare April 23, 2026 16:09
@danny-avila
danny-avila merged commit 9021161 into main Apr 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot install vector extension on remote DB Avoid the call to "create extension" in PostgreSQL (only works as superuser)

1 participant