Duplicate statements after adding .unique()

Starting from a schema that is entirely synced, I add one .unique() constraint on one of my columns, then run drizzle-kit push and I get the following
Warning You are about to execute current statements:

ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);

❯ No, abort
Yes, I want to execute all statements
Warning You are about to execute current statements:

ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);

❯ No, abort
Yes, I want to execute all statements
This will throw InvalidArgument desc = Duplicate key name 'MailingList_email_unique' (errno 1061) (sqlstate 42000) when trying to execute the second statement, but it will at least add it. Now that the key exists, on subsequent calls (without changing anything) it will try to remove it and add it again!
DROP INDEX `MailingList_email_unique` ON ``.`MailingList`;
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
DROP INDEX `MailingList_email_unique` ON ``.`MailingList`;
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
I am using "drizzle-kit": "^0.21.1"and "drizzle-orm": "^0.30.10" and PlanetScale (MySQL). Any support would be greatly appreciated! Thank you.
1 Reply
jt
jt3w ago
I think i'm getting a similar issue here - have raised a bug in github https://github.com/drizzle-team/drizzle-orm/issues/2599
GitHub
[BUG]: · Issue #2599 · drizzle-team/drizzle-orm
What version of drizzle-orm are you using? 0.31.2 What version of drizzle-kit are you using? 0.22.8 Describe the Bug Unique keys aren't able to be reconciled properly using Drizzle with PlanetS...