Skip to content

fix(cli): make migrate --verify a real integrity gate, --plan a pure dry-run - #56

Merged
themixednuts merged 1 commit into
mainfrom
fix/migrate-verify-integrity
Aug 7, 2026
Merged

fix(cli): make migrate --verify a real integrity gate, --plan a pure dry-run#56
themixednuts merged 1 commit into
mainfrom
fix/migrate-verify-integrity

Conversation

@themixednuts

Copy link
Copy Markdown
Owner

Summary

migrate --verify and migrate --plan previously ran identical code and differed only in the final printed line. This differentiates them properly:

  • --verify now checks the tracking table against local migration files — hash drift on applied migrations, applied rows with no local migration, duplicate tracking rows, and interrupted (dirty) migrations — reporting all findings together and exiting non-zero on any.
  • --plan stays a pure dry-run and gains a visible --dry-run alias; it shows the same findings as warnings without failing.
  • --safe now actually runs the verify gate before applying, matching its long-standing docstring.

Bonus fixes surfaced by the restructure: the plan path was counting interrupted (dirty) rows as applied; the duplicate verify_migrations/plan_migrations db functions collapsed to one; six hand-rolled record queries replaced with a dialect-aware Migrations::applied_records_sql() (hash, name, dirty) shared by all drivers including D1.

Test plan

  • cargo test -p drizzle-cli --all-features — includes updated drift test (verify still fails end-to-end) and a new --dry-run warns-but-succeeds counterpart
  • cargo test -p drizzle-migrations — 302 lib tests incl. new applied_records_sql test
  • clippy --all-features --all-targets -D warnings + nightly fmt (pre-commit hook)

🤖 Generated with Claude Code

…dry-run

--verify and --plan previously ran identical code and differed only in the
final printed line. --verify now collects integrity findings between the
tracking table and local files — hash drift on applied migrations, applied
rows missing locally, duplicate tracking rows, and interrupted (dirty)
migrations — and exits non-zero on any, while --plan (new visible alias
--dry-run) reports the same findings as warnings without failing. --safe
runs the verify gate before applying, matching its documentation.

The restructure also fixes the plan path counting interrupted rows as
applied (they now show as pending with a finding), collapses the duplicate
verify_migrations/plan_migrations pair, and replaces six hand-rolled
record queries with a dialect-aware Migrations::applied_records_sql().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@themixednuts themixednuts reopened this Aug 6, 2026
@themixednuts themixednuts reopened this Aug 7, 2026
@themixednuts
themixednuts merged commit 22f5e5d into main Aug 7, 2026
36 checks passed
@themixednuts
themixednuts deleted the fix/migrate-verify-integrity branch August 7, 2026 05:27
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