-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
bugSomething isn't workingSomething isn't workingbug/fixed-in-betaThis bug has been fixed in beta (or will be soon).This bug has been fixed in beta (or will be soon).db/sqlitedrizzle/kitpriorityWill be worked on nextWill be worked on next
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.36.3
What version of drizzle-kit are you using?
0.28.1
Other packages
No response
Describe the Bug
When using drizzle-kit push to update existing table, statements for creating unique index appear twice, leading to SqliteError: index user_email_unique already exists.
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);
PRAGMA foreign_keys=ON;
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);
Table schema
export const user = sqliteTable('user', {
id: text('id').primaryKey().notNull(),
googleId: text('google_id'),
email: text('email').notNull().unique(),
username: text('username').unique(),
...
});SQL statement
PRAGMA foreign_keys=OFF;
CREATE TABLE `__new_user` (
`id` text PRIMARY KEY NOT NULL,
`google_id` text,
`email` text NOT NULL,
`username` text,
...
);
INSERT INTO `__new_user`("id", "google_id", "email", "username", ...) SELECT "id", "google_id", "email", "username", ... FROM `user`;
DROP TABLE `user`;
ALTER TABLE `__new_user` RENAME TO `user`;
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);
PRAGMA foreign_keys=ON;
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);thiagojedi, isnakode, towfiqi, Shenlok, vogler and 12 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingbug/fixed-in-betaThis bug has been fixed in beta (or will be soon).This bug has been fixed in beta (or will be soon).db/sqlitedrizzle/kitpriorityWill be worked on nextWill be worked on next