Repository navigation
Description
Task
T-010b· Milestone M3 — Oracles + runner + store · Size S · Priority P0 · Epic #3Implements FR-STO-001
Branch
feat/t-010b-alembic-setup-and-migration-with— one task = one branch = one PR (doc 32 §6)
Summary
Configure Alembic in backend/migrations/ (env reads database.url from settings) and write 0001_initial reproducing doc 11 §3 exactly, plus a migration test (upgrade → downgrade → upgrade).
Context / motivation
Schema changes happen only through migrations (doc 11 §1); the expand/contract policy (doc 33 §5) depends on a reliable baseline.
Scope
In scope
backend/alembic.ini,backend/migrations/env.py(online/offline, settings-driven URL,compare_type=True).versions/0001_initial.pyhand-reviewed (autogenerate as a starting point, then match the DDL).tests/migrations/test_migrations.py: up/down/up and autogenerate produces no diff against ORM metadata.
Out of scope
roboprobe db upgradeCLI (T-045a)
Implementation guidance
- Never read env vars in
env.pydirectly — callload_settings()(doc 27 §6). Usetransaction_per_migration = True. - Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Acceptance criteria
-
alembic upgrade head/downgrade base/upgrade headsucceed on Postgres 17. - Autogenerate diff after upgrade is empty.
- Migration test runs in the
test-integrationCI job (< 1 min). - Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
backend/tests/migrations/test_migrations.py.
Dependencies
Blocked by: #59 (T-010a)
Blocks: #61 (T-011a), #89 (T-045a)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
backend/alembic.inibackend/migrations/**backend/tests/migrations/test_migrations.py
Sequential after T-010a; independent of repositories work once merged.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-010b (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 11 §3 · doc 33 §5 · doc 18 §2
Requirements: FR-STO-001 (traceability: doc 28)
External:
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity
db upgradeandspace validate|register|list#89