Skip to content

Commit

Permalink
Remove checkpoint_ns from primary keys.
Browse files Browse the repository at this point in the history
At the same time, increase its max size to 2000 characters. We do this
because with nested subgraphs, we hit the original 100 character limit
way too quickly.

We have to remove it from the primary key because primary keys are
limited to 767 bytes in MySQL.
  • Loading branch information
tjni committed Dec 21, 2024
1 parent 4299a51 commit 65161d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions langgraph/checkpoint/mysql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@
"ALTER TABLE checkpoints MODIFY COLUMN `checkpoint_ns` VARCHAR(255) NOT NULL DEFAULT '';",
"ALTER TABLE checkpoint_blobs MODIFY COLUMN `checkpoint_ns` VARCHAR(255) NOT NULL DEFAULT '';",
"ALTER TABLE checkpoint_writes MODIFY COLUMN `checkpoint_ns` VARCHAR(255) NOT NULL DEFAULT '';",
"""
ALTER TABLE checkpoints
DROP PRIMARY KEY,
ADD PRIMARY KEY (thread_id, checkpoint_id),
MODIFY COLUMN `checkpoint_ns` VARCHAR(2000) NOT NULL DEFAULT '';
""",
"""
ALTER TABLE checkpoint_blobs
DROP PRIMARY KEY,
ADD PRIMARY KEY (thread_id, channel, version),
MODIFY COLUMN `checkpoint_ns` VARCHAR(2000) NOT NULL DEFAULT '';
""",
"""
ALTER TABLE checkpoint_writes
DROP PRIMARY KEY,
ADD PRIMARY KEY (thread_id, checkpoint_id, task_id, idx),
MODIFY COLUMN `checkpoint_ns` VARCHAR(2000) NOT NULL DEFAULT '';
""",
]

SELECT_SQL = f"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-checkpoint-mysql"
version = "2.0.8"
version = "2.0.9"
description = "Library with a MySQL implementation of LangGraph checkpoint saver."
authors = ["Theodore Ni <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 65161d9

Please sign in to comment.