Skip to content
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

[BUG]: Cannot drop Unique Constraint MySQL #998

Closed
skusez opened this issue Aug 8, 2023 · 3 comments
Closed

[BUG]: Cannot drop Unique Constraint MySQL #998

skusez opened this issue Aug 8, 2023 · 3 comments
Labels
bug Something isn't working db/mysql drizzle/kit priority Will be worked on next

Comments

@skusez
Copy link

skusez commented Aug 8, 2023

What version of drizzle-orm are you using?

0.28.1

What version of drizzle-kit are you using?

0.19.12

Describe the Bug

  1. Create a mysql table with a unique constraint
  2. Drizzle-kit push
  3. Delete the unique constraint
  4. Drizzle-kit push

The ORM attempts to do the following:

ALTER TABLE MyTableDROP CONSTRAINTMyTable_MyKey_key``

whereas it should be executing this:

ALTER TABLE MyTableDROP INDEXMyTable_MyKey_key``

This is preventing pushes to the DB and errors in the console.

Expected behavior

Key should be dropped and drizzle-kit should push without issues.

Environment & setup

Planetscale DB connection in node.js 18 environment

@skusez skusez added the bug Something isn't working label Aug 8, 2023
@masonbrothers
Copy link

masonbrothers commented Nov 8, 2023

I think we need to use something like this for MySQL if you are using foreign keys. I don't think PlanetScale supports them.

ALTER TABLE MyTable DROP FOREIGN KEY IF EXISTS MyTable_MyKey_key;
ALTER TABLE MyTable DROP INDEX IF EXISTS MyTable_MyKey_key;

Source: https://stackoverflow.com/a/18317774

@moh682
Copy link

moh682 commented Dec 26, 2023

I'm also experiencing the same issue now. Foreign Keys are being supported by PlanetScale, the feature is currently in beta.

@AndriiSherman
Copy link
Member

Was fixed in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working db/mysql drizzle/kit priority Will be worked on next
Projects
None yet
Development

No branches or pull requests

6 participants