feat(persistence): 4 business ORM models — nullable workspace_id

ORM-side mirror of alembic 0002. threads_meta gets the matching
(workspace_id, user_id, updated_at) composite index so fresh
create_all() dev databases land on the same shape Alembic produces.
Pre-existing test_alembic_default_workspace_id pins to revision
0001 explicitly since 'head' now includes 0002.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1445043649
2026-05-13 09:06:08 +08:00
parent 4e26ec9884
commit d3361dba59
5 changed files with 37 additions and 7 deletions
@@ -97,7 +97,7 @@ def test_sqlite_upgrade_adds_default_workspace_id_with_fk() -> None:
_bootstrap_pre_pr4_schema(sync_url)
cfg = _make_alembic_config(async_url)
command.upgrade(cfg, "head")
command.upgrade(cfg, "0001_users_default_workspace")
_assert_column_present(sync_url)
@@ -112,7 +112,7 @@ def test_sqlite_downgrade_removes_default_workspace_id() -> None:
_bootstrap_pre_pr4_schema(sync_url)
cfg = _make_alembic_config(async_url)
command.upgrade(cfg, "head")
command.upgrade(cfg, "0001_users_default_workspace")
_assert_column_present(sync_url)
command.downgrade(cfg, "-1")