Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

docs(guides): backend-specific v3→v4 migration notes

xf gongd482eda119af
diff --git a/website/docs/guides/checkpointing/mysql.md b/website/docs/guides/checkpointing/mysql.md
index 8925687..f7c61c7 100644
--- a/website/docs/guides/checkpointing/mysql.md
+++ b/website/docs/guides/checkpointing/mysql.md
@@ -195,6 +195,35 @@ claim/completion state.
See the [Conversation Forking](./forking) guide for the user-facing
API and semantics.
+## Schema v3 → v4 migration
+
+The fork feature bumps `EXPECTED_SCHEMA_VERSION` from 3 to 4. The
+upgrade adds the `run_id` column + composite index to
+`cubepi_messages` and creates the `cubepi_runs` table. Use the
+provided alembic helper — MySQL/pymysql executes one statement per
+call, so split before executing:
+
+```python
+# In a migration's upgrade():
+from cubepi.checkpointer.mysql.alembic_helpers import (
+ upgrade_v3_to_v4_op,
+ write_schema_version_op,
+)
+
+def upgrade():
+ for stmt in upgrade_v3_to_v4_op().split(";"):
+ if stmt.strip():
+ op.execute(stmt)
+ for stmt in write_schema_version_op().split(";"):
+ if stmt.strip():
+ op.execute(stmt)
+```
+
+`upgrade_v3_to_v4_op()` is idempotent under repeated execution.
+Pre-feature messages keep `run_id = NULL` and remain readable; see
+[Legacy data behaviour](./forking#legacy-data-behaviour) for the
+fork-eligibility rules on mixed threads.
+
## Common pitfalls
- **`CubepiSchemaUninitialized`** — Your DB is empty, your migrations
diff --git a/website/docs/guides/checkpointing/postgres.md b/website/docs/guides/checkpointing/postgres.md
index 86ec977..fc7656e 100644
--- a/website/docs/guides/checkpointing/postgres.md
+++ b/website/docs/guides/checkpointing/postgres.md
@@ -187,6 +187,32 @@ per-run claim/completion state.
See the [Conversation Forking](./forking) guide for the user-facing
API and semantics.
+## Schema v3 → v4 migration
+
+The fork feature bumps `EXPECTED_SCHEMA_VERSION` from 3 to 4. The
+upgrade adds the `run_id` column + index to `cubepi_messages` and
+creates a partitioned `cubepi_runs` parent table with its child
+partitions. Use the provided alembic helper:
+
+```python
+# In a migration's upgrade():
+from cubepi.checkpointer.postgres.alembic_helpers import (
+ upgrade_v3_to_v4_op,
+ write_schema_version_op,
+)
+
+def upgrade():
+ op.execute(upgrade_v3_to_v4_op())
+ op.execute(write_schema_version_op()) # bumps cubepi_schema_version to 4
+```
+
+`upgrade_v3_to_v4_op()` is idempotent under repeated execution
+(`IF NOT EXISTS` guards on every DDL statement).
+
+Pre-feature messages keep `run_id = NULL` and remain readable; see
+[Legacy data behaviour](./forking#legacy-data-behaviour) for the
+fork-eligibility rules on mixed threads.
+
## Common pitfalls
- **`CubepiSchemaUninitialized`** — Your DB is empty or your
diff --git a/website/docs/guides/checkpointing/sqlite.md b/website/docs/guides/checkpointing/sqlite.md
index cdd9107..c44603e 100644
--- a/website/docs/guides/checkpointing/sqlite.md
+++ b/website/docs/guides/checkpointing/sqlite.md
@@ -146,6 +146,18 @@ If you need multi-process writers on shared threads, jump to
so it supports both `Agent.fork(...)` and `Agent.fork_once(...)`. See
the [Conversation Forking](./forking) guide for the user-facing API.
+## Schema v3 → v4 migration
+
+Unlike Postgres and MySQL, SQLite's schema is managed by CubePi
+itself: the v3→v4 upgrade (adding `run_id` to `messages` and
+creating a `cubepi_runs` table) runs automatically on `__aenter__`
+the first time a v4 CubePi connects to a v3 file. No host action is
+required.
+
+Pre-feature messages keep `run_id = NULL` and remain readable; see
+[Legacy data behaviour](./forking#legacy-data-behaviour) for the
+fork-eligibility rules on mixed threads.
+
## Where the file lives
Use an absolute path in production: