Skip to content

Commit a1b34ef

Browse files
fix(checkpoint-postgres): ensure vector extension is created only if not exists (#6154)
Thank you for contributing to LangGraph! Follow these steps to mark your pull request as ready for review. **If any of these steps are not completed, your PR will not be considered for review.** - [x] **PR title**: Follows the format: {TYPE}({SCOPE}): {DESCRIPTION} - Examples: - feat(core): add multi-tenant support - fix(cli): resolve flag parsing error - docs(openai): update API usage examples - Allowed `{TYPE}` values: - feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, release - Allowed `{SCOPE}` values (optional): - langgraph, docs, cli, checkpoint, checkpoint-postgres, checkpoint-sqlite, prebuilt, scheduler-kafka, sdk-py - Once you've written the title, please delete this checklist item; do not include it in the PR. - **Description:** Azure Postgres SQL server has a limitation when doing create extension vector is not exists, even though it manually created before on a schema. - **Issue:** Even though `CREATE EXTENSION vector` is executed manually before, the permission issue arises. Putting it in an if else block solves the issue and its not a breaking change. ``` Because vector isn't a trusted extension, only members of "azure_pg_admin" are allowed to use CREATE EXTENSION vector HINT: to learn how to allow an extension or see the list of allowed extensions, please refer to https://go.microsoft.com/fwlink/?linkid=2301063 ``` Co-authored-by: Josh Rogers <[email protected]>
1 parent 7ab5788 commit a1b34ef

File tree

1 file changed

+6
-1
lines changed
  • libs/checkpoint-postgres/langgraph/store/postgres

1 file changed

+6
-1
lines changed

libs/checkpoint-postgres/langgraph/store/postgres/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ class Migration(NamedTuple):
9191
VECTOR_MIGRATIONS: Sequence[Migration] = [
9292
Migration(
9393
"""
94-
CREATE EXTENSION IF NOT EXISTS vector;
94+
DO $$
95+
BEGIN
96+
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector') THEN
97+
CREATE EXTENSION vector;
98+
END IF;
99+
END $$;
95100
""",
96101
),
97102
Migration(

0 commit comments

Comments
 (0)