feat(common): add rollback_migrations helper to agentd_common::storage#1130
feat(common): add rollback_migrations helper to agentd_common::storage#1130geoffjay wants to merge 2 commits intofeature/corefrom
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
Adds rollback_migrations<M>(db_path, steps) following the same pattern as apply_migrations and migration_status. steps=None rolls back all applied migrations; steps=Some(n) rolls back the n most recent. Closes #1123
geoffjay
left a comment
There was a problem hiding this comment.
Review: feat(common): add rollback_migrations helper to agentd_common::storage
LGTM — cannot self-approve, posting as comment.
Stack note
This branch (issue-1123) is the base of the entire core migration stack. The chain above it is:
- #1131 (issue-1124): expose helpers from
agentd_core::lib - #1132 (issue-1125): clap CLI with migrate subcommand
- #1133 (issue-1127): integration tests for the CLI
- #1134 (issue-1126): xtask registration
This PR must merge first; everything else in the stack depends on rollback_migrations being available in agentd_common::storage.
Base branch observation (non-blocking): This PR targets feature/core which itself targets main. CLAUDE.md specifies all feature work should PR into feature/autonomous-pipeline, not main. feature/core (#1135) appears to be a legitimate collecting branch for core service work, so this is likely intentional — but worth confirming the feature/core → main targeting is deliberate before the final merge.
What was verified
- Pattern match: structure is identical to
apply_migrations—create_connectionthen the SeaORM migrator call thenOk(()). ✓ - SeaORM API:
MigratorTrait::down(&db, steps)is the correct call;None= roll back all,Some(n)= roll back n most recent. Matches the doc comment exactly. ✓ - Error propagation: both
create_connectionandM::downuse?— nounwrapanywhere. ✓ - No connection leak:
dbis local and dropped at end of function. ✓ - Placement: inserted between
apply_migrationsandmigration_status— logical ordering of the three migration operations. ✓ - Docs:
stepssemantics documented inline with the bullet-point convention used elsewhere. ✓ - Scope: one function, 13 lines, no other changes. ✓
Non-blocking suggestion
A unit test for rollback_migrations would complete the test coverage alongside the existing test_create_connection / test_create_connection_creates_file tests. The function has no internal logic to test beyond the delegation, so the integration tests in #1133 provide adequate coverage — but a direct test like:
#[tokio::test]
async fn test_rollback_migrations_is_callable() {
// smoke-test: apply then roll back using a concrete Migrator
}would guard against future signature drift. Non-blocking; can be a follow-up.
Adds
rollback_migrations<M>(db_path, steps)toagentd_common::storage, following the same pattern asapply_migrationsandmigration_status.steps=Nonerolls back all applied migrations;steps=Some(n)rolls back the n most recent.Closes #1123