Skip to content

Conversation

isaacwasserman
Copy link

@isaacwasserman isaacwasserman commented Sep 17, 2025

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
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