Skip to content

Add baseline command for migration cleanup#13

Merged
rwdaigle merged 2 commits intomainfrom
ryan/migration-cleanup
Jan 26, 2026
Merged

Add baseline command for migration cleanup#13
rwdaigle merged 2 commits intomainfrom
ryan/migration-cleanup

Conversation

@rwdaigle
Copy link
Contributor

@rwdaigle rwdaigle commented Jan 26, 2026

Summary

Adds the migrate baseline <version> command which marks a specific version as the baseline, allowing old migration files to be deleted while preserving history. This enables migration cleanup and reduces repository bloat over time.

  • New migrate baseline <version> command to mark versions as applied
  • --baseline and --keep flags on migrate up for inline baselining
  • .baseline file tracks baseline version and optional summary
  • Documentation updated in README.md and CLAUDE.md
  • Version bumped to 0.4.0

Test plan

  • All 48 existing tests pass
  • New baseline functionality tested via unit tests in src/baseline.rs
  • Version consistency enforced through Cargo.toml

🤖 Generated with Claude Code


Open with Devin

rwdaigle and others added 2 commits January 26, 2026 14:16
Adds the `migrate baseline <version>` command which marks a specific
version as the baseline, allowing old migration files to be deleted
while preserving history. Also adds `--baseline` and `--keep` flags
to the `up` command.

- Add src/baseline.rs for baseline file management
- Add src/commands/baseline.rs for CLI command
- Update status and up commands to respect baselines
- Update documentation in README.md and CLAUDE.md
- Bump version to 0.4.0 (new feature)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reorganize documentation to follow the natural migration workflow:
creating, writing, applying, checking status, and baselining. Add
practical guidance on when to use each feature and what happens
under the hood.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rwdaigle rwdaigle merged commit c985d00 into main Jan 26, 2026
4 checks passed
@rwdaigle rwdaigle deleted the ryan/migration-cleanup branch January 26, 2026 19:23
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Comment on lines +91 to +93
let is_baselined = baseline
.as_ref()
.is_some_and(|b| extract_version(&migration.id) <= Some(b.version.clone()));

Choose a reason for hiding this comment

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

🟡 Malformed migration IDs incorrectly marked as baselined due to Option comparison

In the status command, when checking if a migration is baselined, the code compares extract_version(&migration.id) <= Some(b.version.clone()). The extract_version function returns None for malformed migration IDs (those that don't have a dash at position 5).

Click to expand

Issue Details

In Rust, None < Some(_) is always true due to how Option ordering works. This means if a migration ID in the .history file is malformed (e.g., manually edited), the comparison None <= Some(baseline_version) would evaluate to true, causing that migration to be incorrectly displayed with the (baseline) marker.

// src/commands/status.rs:91-93
let is_baselined = baseline
    .as_ref()
    .is_some_and(|b| extract_version(&migration.id) <= Some(b.version.clone()));

The extract_version function at lines 123-129 returns None when the ID doesn't match the expected format:

fn extract_version(id: &str) -> Option<String> {
    if id.len() >= 5 && id.chars().nth(5) == Some('-') {
        Some(id[..5].to_string())
    } else {
        None
    }
}

Impact

This is a display-only bug affecting the migrate status output. It doesn't affect actual migration behavior or data integrity.

Recommendation: Change the comparison to handle the None case explicitly, e.g., extract_version(&migration.id).map_or(false, |v| v <= b.version)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant