Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
isaacwasserman wants to merge 2 commits into drizzle-team:main
base: main
Choose a base branch
Loading
from isaacwasserman:feat/migration-squash

Conversation

Copy link

@isaacwasserman isaacwasserman commented Sep 17, 2025
edited
Loading

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

boredland, jenslys, CyanCX2, cmanou, and lukaspili reacted with thumbs up emoji
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /