From ff38f75594cfeb0a7792a763a2ea78a3f02db806 Mon Sep 17 00:00:00 2001 From: Josh Rogers Date: Thu, 6 Nov 2025 09:49:51 -0500 Subject: [PATCH] fix(checkpoint-postgres): make async PG checkpoint migration idempotent (#6400) - **Description:** The final migration for the postgres checkpointer is not currently idempotent. That presents problems when migrating from one checkpointer to another or if migrations otherwise get applied twice. This makes the final migration idempotent to avoid this problem. - **Issue:** N/A - **Dependencies:** N/A - **Twitter handle:** N/A --- libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py | 2 +- .../langgraph/checkpoint/postgres/shallow.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py index b66c0e4a2..8f27fee5b 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py @@ -81,7 +81,7 @@ MIGRATIONS = [ """ CREATE INDEX CONCURRENTLY IF NOT EXISTS checkpoint_writes_thread_id_idx ON checkpoint_writes(thread_id); """, - """ALTER TABLE checkpoint_writes ADD COLUMN task_path TEXT NOT NULL DEFAULT '';""", + """ALTER TABLE checkpoint_writes ADD COLUMN IF NOT EXISTS task_path TEXT NOT NULL DEFAULT '';""", ] SELECT_SQL = """ diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py index 3506a4836..024df3848 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py @@ -77,7 +77,7 @@ MIGRATIONS = [ CREATE INDEX CONCURRENTLY IF NOT EXISTS checkpoint_writes_thread_id_idx ON checkpoint_writes(thread_id); """, """ - ALTER TABLE checkpoint_writes ADD COLUMN task_path TEXT NOT NULL DEFAULT ''; + ALTER TABLE checkpoint_writes ADD COLUMN IF NOT EXISTS task_path TEXT NOT NULL DEFAULT ''; """, ]