Open jmyt8 opened 5 days ago
i have a very similar problem.
i did the following:
it tries to add another index that doesn't exist in the current database, not in the schema or anywhere else as far as i know.
this is the generated sql file:
CREATE TABLE `setting` (
`id` integer PRIMARY KEY NOT NULL,
`key` text NOT NULL,
`value` text NOT NULL,
`user_id` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `setting_key_unique` ON `setting` (`key`);--> statement-breakpoint
CREATE UNIQUE INDEX `user_setting_idx` ON `setting` (`user_id`,`key`);--> statement-breakpoint`
this is the schema for setting:
export const setting = sqliteTable(
'setting',
{
id: integer().primaryKey().notNull(),
key: text().notNull().unique(),
value: text().notNull(),
userId: text('user_id')
.notNull()
.references(() => user.id)
},
(table) => ({
userSettingsIndex: uniqueIndex('user_setting_idx').on(table.userId, table.key)
})
);```
setting_key_unique index is created because you set setting.key to be unique.
UNIQUE constraints are implemented by creating a unique index in the database
Thank you so much. But should drizzle-kit recognize that?
jmyt8 @.***> schrieb am Mo. 18. Nov. 2024 um 02:20:
setting_key_unique index is created because you set setting.key to be unique.
UNIQUE constraints are implemented by creating a unique index in the database
— Reply to this email directly, view it on GitHub https://github.com/drizzle-team/drizzle-orm/issues/3574#issuecomment-2481740884, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGM6JJWVTOASYUE4CAJIFL2BE6ELAVCNFSM6AAAAABR546QOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBRG42DAOBYGQ . You are receiving this because you commented.Message ID: @.***>
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.
Table schema
SQL statement