Skip to content

[Drizzle-kit]: Add "squash" command to CLI - #4927

Open
isaacwasserman wants to merge 4 commits into
drizzle-team:mainfrom
isaacwasserman:feat/migration-squash
Open

[Drizzle-kit]: Add "squash" command to CLI#4927
isaacwasserman wants to merge 4 commits into
drizzle-team:mainfrom
isaacwasserman:feat/migration-squash

Conversation

@isaacwasserman

@isaacwasserman isaacwasserman commented Sep 17, 2025

Copy link
Copy Markdown

This commit adds a 'squash' command to the drizzle-kit cli. This command allows users to combine a range of consecutive migrations. Squashing is particularly useful for cleaning up feature branches developed over multiple iterations that include many small, redundant, or contradictory migrations.

Changes:

  • Adds squash command to CLI schema
  • Implements squash command
    • Takes two custom arguments start (i) and end (j) representing the inclusive range of migrations to be merged
    • Combines migrations
      • Concatenates SQL files
      • Updates journal entry i to use snapshot from migration j
      • Removes journal entries i+1-j
      • Removes unused sql and snapshots
  • No pre-existing code is modified or deleted
  • Integration tests are included to ensure:
    • Basic functionality of CLI
    • Compatibility with existing generate and migrate commands

Note:
The squash command has a single known (and intentional) failure case when some environment has been migrated to version i < k < j.

Related issues/discussions: #2859 #4897 #3492

This commit adds a 'squash' command to the drizzle-kit cli. This command allows users to combine a range of consecutive migrations. Squashing is particularly useful for cleaning up feature branches developed over multiple iterations that include many small, redundant, or contradictory migrations.
Cleaned up code formatting and style using prettier and eslint
@isaacwasserman
isaacwasserman marked this pull request as ready for review September 17, 2025 21:15

@bhawanibytes bhawanibytes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does is support current stable version??

@isaacwasserman

Copy link
Copy Markdown
Author

does is support current stable version??

@bhawanibytes yes, it does support the current stable version, but I'll need to make a separate pr into the beta branch to support the new migration strategy.

…with 0.25.0

The 0.25.0-b1faa33 canary tarball was removed from npm, causing
ERR_PNPM_FETCH_404 during pnpm install in the Release Router workflow.
@isaacwasserman

Copy link
Copy Markdown
Author

See #6150 for the pr aimed at the beta version.

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.

2 participants