[PR #838] [MERGED] feat(checkpoint-postgres): Add support for providing a custom schema during initialization #1052

Closed
opened 2026-02-15 19:16:58 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/838
Author: @nick-w-nick
Created: 2/2/2025
Status: Merged
Merged: 2/20/2025
Merged by: @benjamincburns

Base: mainHead: feature/add-schema-support-to-postgres


📝 Commits (10+)

  • 057e586 updated migrations to accept a custom schema value
  • 5c1a89e updated sql queries to accept a custom schema value
  • cfcd9e4 updated setup method to use the custom schema provided
  • 2256251 updated checkpoint saver methods to use the custom schema queries
  • 85013ed added log for database creation
  • 809750a added custom schema param
  • bba58c8 added clarifying comment regarding trailing space to prevent it from being removed by mistake
  • 384f82b updated test to run both with and without a custom schema to test default behavior
  • 6874e6a updated readme to include how to provide a custom schema
  • 010d65a added jsdoc for the fromConnString method

📊 Changes

5 files changed (+215 additions, -111 deletions)

View changed files

📝 libs/checkpoint-postgres/README.md (+4 -1)
📝 libs/checkpoint-postgres/src/index.ts (+74 -19)
📝 libs/checkpoint-postgres/src/migrations.ts (+42 -37)
📝 libs/checkpoint-postgres/src/sql.ts (+76 -48)
📝 libs/checkpoint-postgres/src/tests/checkpoints.int.test.ts (+19 -6)

📄 Description

This PR adds support for specifying a custom schema in the checkpoint-postgres module during initialization. Instead of relying on the default public schema used by Postgres or modifying the connection string’s search path (which can be unreliable at best), SQL queries now explicitly reference the provided schema, ensuring compatibility across all PostgreSQL versions and configurations, while still allowing the original module to stay backward compatible with previous versions since public was already the default schema.

// you can optionally pass a configuration object as the second parameter
const checkpointer = PostgresSaver.fromConnString("postgresql://...", {
  schema: "schema_name" // defaults to "public"
});

Key Changes

  • Custom Schema Support
    • Added an extendable options parameter to specify a schema when creating a PostgresSaver instance via the fromConnString method
    • Consolidated SQL queries and migration scripts into reusable functions that accept a schema name
  • Documentation & Testing
    • Improved JSDoc comments for fromConnString with usage example
    • Enhanced integration tests to validate behavior with both the default and a custom schema

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraphjs/pull/838 **Author:** [@nick-w-nick](https://github.com/nick-w-nick) **Created:** 2/2/2025 **Status:** ✅ Merged **Merged:** 2/20/2025 **Merged by:** [@benjamincburns](https://github.com/benjamincburns) **Base:** `main` ← **Head:** `feature/add-schema-support-to-postgres` --- ### 📝 Commits (10+) - [`057e586`](https://github.com/langchain-ai/langgraphjs/commit/057e58648e176f9629737e9b17cfa3664e45ad3d) updated migrations to accept a custom schema value - [`5c1a89e`](https://github.com/langchain-ai/langgraphjs/commit/5c1a89e0466a94cdffa57d01430279d4e6d1dea5) updated sql queries to accept a custom schema value - [`cfcd9e4`](https://github.com/langchain-ai/langgraphjs/commit/cfcd9e4fd4ef0aab7b003d4d2ae96df9f7956933) updated setup method to use the custom schema provided - [`2256251`](https://github.com/langchain-ai/langgraphjs/commit/2256251afb963196707ad4f0cebb01fcd1591449) updated checkpoint saver methods to use the custom schema queries - [`85013ed`](https://github.com/langchain-ai/langgraphjs/commit/85013edb42e36e63b3c59ebdb20f17ac6f58466b) added log for database creation - [`809750a`](https://github.com/langchain-ai/langgraphjs/commit/809750a6b4138c222ed5a7b9a21d59bd786397b0) added custom schema param - [`bba58c8`](https://github.com/langchain-ai/langgraphjs/commit/bba58c8e07cbf135aacb314d00590418a8fedb1f) added clarifying comment regarding trailing space to prevent it from being removed by mistake - [`384f82b`](https://github.com/langchain-ai/langgraphjs/commit/384f82b2f477266746f3d344cac1e2d48a399127) updated test to run both with and without a custom schema to test default behavior - [`6874e6a`](https://github.com/langchain-ai/langgraphjs/commit/6874e6ae3fba84dc845cd0ebb92d28ea794a9dac) updated readme to include how to provide a custom schema - [`010d65a`](https://github.com/langchain-ai/langgraphjs/commit/010d65a0c476274a817da77b3fa147daf0ae483c) added jsdoc for the fromConnString method ### 📊 Changes **5 files changed** (+215 additions, -111 deletions) <details> <summary>View changed files</summary> 📝 `libs/checkpoint-postgres/README.md` (+4 -1) 📝 `libs/checkpoint-postgres/src/index.ts` (+74 -19) 📝 `libs/checkpoint-postgres/src/migrations.ts` (+42 -37) 📝 `libs/checkpoint-postgres/src/sql.ts` (+76 -48) 📝 `libs/checkpoint-postgres/src/tests/checkpoints.int.test.ts` (+19 -6) </details> ### 📄 Description This PR adds support for specifying a custom schema in the `checkpoint-postgres` module during initialization. Instead of relying on the default `public` schema used by Postgres or modifying the connection string’s search path (which can be unreliable at best), SQL queries now explicitly reference the provided schema, ensuring compatibility across all PostgreSQL versions and configurations, while still allowing the original module to stay backward compatible with previous versions since `public` was already the default schema. ```ts // you can optionally pass a configuration object as the second parameter const checkpointer = PostgresSaver.fromConnString("postgresql://...", { schema: "schema_name" // defaults to "public" }); ``` ### Key Changes - **Custom Schema Support** - Added an extendable `options` parameter to specify a schema when creating a `PostgresSaver` instance via the `fromConnString` method - Consolidated SQL queries and migration scripts into reusable functions that accept a schema name - **Documentation & Testing** - Improved JSDoc comments for `fromConnString` with usage example - Enhanced integration tests to validate behavior with both the default and a custom schema --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 19:16:58 -05:00
yindo closed this issue 2026-02-15 19:16:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#1052