Skip to content

[drizzle-kit]: Fix push deleting then re-adding unchanged unique constraints #4565

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

f1yingbanana
Copy link

@f1yingbanana f1yingbanana commented May 26, 2025

Fix drizzle-kit push deleting then re-adding unchanged unique constraints.

During push, the TS schema and database might have different column orders in unique keys, resulting in drizzle-kit push deleting then readding the same unique constraint (and generating a warning that needs to be manually responded to too). This PR adds sort() to all squashUnique() methods.

This fixes #2888. I know there are a couple of other fixes out there (as part of #3999 and part of #4043), but I believe this to be a much more concise solution.

See my original discussion for a deep-dive of why this is happening #2888 (comment)

@maxpaj
Copy link

maxpaj commented Jun 13, 2025

Please merge.

@rebasecase
Copy link

Add tests.

@f1yingbanana
Copy link
Author

The new drizzle-kit should land any moment now folks, let's hope this is fixed in there 🥲

@cameronmema
Copy link

when will this be added?

@dsbrianwebster
Copy link

🙏 🚀

@dsbrianwebster
Copy link

Would love to see this and #3092 get merged to clear up two issues around unique constraints.

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.

[BUG]: the order of columns is causing redeclaration of UNIQUE constraint when using "drizzle-kit push"
5 participants