Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(persistence): chain the chat sessions migration after change records as 0111 (#3763)

Raghav Chamadiyaaac065b8c0d0
diff --git a/packages/core/alembic/versions/0110_chat_sessions.py b/packages/core/alembic/versions/0111_chat_sessions.py
similarity index 96%
rename from packages/core/alembic/versions/0110_chat_sessions.py
rename to packages/core/alembic/versions/0111_chat_sessions.py
index c24d40c9e..98e6d3e7e 100644
--- a/packages/core/alembic/versions/0110_chat_sessions.py
+++ b/packages/core/alembic/versions/0111_chat_sessions.py
@@ -9,8 +9,8 @@ conversation, so a retried send returns the stored reply.
Local SQLite stores never run Alembic; ``init_db`` adds the columns and indexes
there from the model.
-Revision ID: 0110
-Revises: 0109
+Revision ID: 0111
+Revises: 0110
Create Date: 2026-10-14
"""
@@ -22,8 +22,8 @@ import sqlalchemy as sa
from alembic import op
# revision identifiers
-revision: str = "0110"
-down_revision: str | None = "0109"
+revision: str = "0111"
+down_revision: str | None = "0110"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
diff --git a/tests/unit/persistence/test_migration_single_head.py b/tests/unit/persistence/test_migration_single_head.py
new file mode 100644
index 000000000..709adac32
--- /dev/null
+++ b/tests/unit/persistence/test_migration_single_head.py
@@ -0,0 +1,34 @@
+"""The Alembic chain has one head and no duplicated revision ids.
+
+Two branches that each add the next-numbered migration both merge cleanly in
+git, so the clash only shows when a database upgrades.
+"""
+
+from __future__ import annotations
+
+from collections import Counter
+from pathlib import Path
+
+from alembic.config import Config
+from alembic.script import ScriptDirectory
+
+_ALEMBIC = Path(__file__).resolve().parents[3] / "packages" / "core" / "alembic"
+
+
+def _script() -> ScriptDirectory:
+ config = Config()
+ config.set_main_option("script_location", str(_ALEMBIC))
+ return ScriptDirectory.from_config(config)
+
+
+def test_one_head():
+ assert len(_script().get_heads()) == 1
+
+
+def test_revision_ids_are_unique():
+ ids = Counter()
+ for path in (_ALEMBIC / "versions").glob("*.py"):
+ for line in path.read_text(encoding="utf-8").splitlines():
+ if line.startswith("revision:"):
+ ids[line.split("=", 1)[1].strip().strip("\"'")] += 1
+ assert [rev for rev, n in ids.items() if n > 1] == []