Skip to content

feat(common): add rollback_migrations helper to agentd_common::storage#1130

Open
geoffjay wants to merge 2 commits intofeature/corefrom
issue-1123
Open

feat(common): add rollback_migrations helper to agentd_common::storage#1130
geoffjay wants to merge 2 commits intofeature/corefrom
issue-1123

Conversation

@geoffjay
Copy link
Copy Markdown
Owner

Adds rollback_migrations<M>(db_path, steps) to agentd_common::storage, 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 geoffjay added the review-agent Used to invoke a review by an agent tracking this label label Apr 16, 2026
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
Copy link
Copy Markdown
Owner Author

@geoffjay geoffjay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/coremain targeting is deliberate before the final merge.

What was verified

  • Pattern match: structure is identical to apply_migrationscreate_connection then the SeaORM migrator call then Ok(()). ✓
  • 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_connection and M::down use ? — no unwrap anywhere. ✓
  • No connection leak: db is local and dropped at end of function. ✓
  • Placement: inserted between apply_migrations and migration_status — logical ordering of the three migration operations. ✓
  • Docs: steps semantics 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.

@geoffjay geoffjay added merge-queue Approved by reviewer, queued for merge by conductor and removed review-agent Used to invoke a review by an agent tracking this label labels Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-queue Approved by reviewer, queued for merge by conductor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant