Skip to content

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

Open
isaacwasserman wants to merge 1 commit into
drizzle-team:betafrom
isaacwasserman:feat/migration-squash-v3
Open

[Drizzle-kit]: Add "squash" command to CLI#6150
isaacwasserman wants to merge 1 commit into
drizzle-team:betafrom
isaacwasserman:feat/migration-squash-v3

Conversation

@isaacwasserman

@isaacwasserman isaacwasserman commented Aug 20, 2026

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.

This is the beta (v3 folder-based migration format) port of #4927.

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

Port the squash feature to the beta branch's DAG-aware migration model.
The command combines a range of consecutive migrations into a single
migration folder, preserves the snapshot chain (keeps the last snapshot's
id and the first snapshot's prevIds), regenerates the migrations.js
bundle when present, and guards against squashing across branches or
merges in the DAG.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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