Skip to content

[drizzle-kit] Add push flag for safe use in non-interactive CI #4384

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carderne
Copy link

@carderne carderne commented Apr 8, 2025

I know the docs suggest using drizzle-kit push in CI is a bad idea, but it works fine if you only do backward-compatible changes, and the push command is so close to supporting this use-case.

All it needs is an option to only to non-destructive stuff, which I've added here as a --safe flag.

I just put this up as a feeler covering the most basic use case of data loss. It should also handle things like making a column unique or notNull, by defaulting to try the change in a safe way (option 0), failing if it doesn't work.

Usage example

> drizzle-kit push --safe

[✓] Pulling schema from database...
 Warning  Found data-loss statements:
· You're about to delete foo column in bar table with 10 items

Safe mode is enabled - aborting

Todo

  • handle unique/notNull etc constraints
  • choose a better name for the flag than --safe? Could be --no-data-loss or --non-interactive...?
  • add tests
  • test it more
  • update docs

Relevant issues

#3209

@carderne carderne changed the title add safe option for ci usage [drizzle-kit] Add push flag for safe use in non-interactive CI Apr 10, 2025
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