-
-
Notifications
You must be signed in to change notification settings - Fork 766
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]: drizzle-kit generate
ignores index operators
#2935
Comments
Maybe this will help. I have a column idx_metadata_email_trgm: index('idx_metadata_email_trgm').using(
'gin',
sql.raw("(metadata->>'email') gin_trgm_ops"),
), I think you will be able to adapt your syntax using |
Was fixed in |
Same problem "drizzle-orm": "^0.38.3" export const chats = pgTable('chats', {
id: uuid('id').defaultRandom().primaryKey(),
chatId: varchar('chat_id', { length: 256 }).notNull(),
contactId: uuid('contact_id').references(() => contacts.id, { onDelete: 'cascade' }),
whatsappId: uuid('whatsapp_id').references(() => whatsapps.id, { onDelete: 'cascade' }).notNull(),
name: varchar('name', { length: 256 }).notNull(),
customName: varchar('custom_name', { length: 256 }),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at'),
}, (table) => [{
chat_whatsapp_idx: uniqueIndex('chat_whatsapp_idx').on(table.chatId, table.whatsappId),
}]);
export type Chat = typeof chats.$inferSelect;
export type InsertChat = typeof chats.$inferInsert; generated CREATE TABLE "chats" ( ALTER TABLE "chats" ADD CONSTRAINT "chats_contact_id_contacts_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."contacts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint |
Nevermind, I coded wrong syntax, this is the correct syntax for indexes export const chats = pgTable('chats', {
id: uuid('id').defaultRandom().primaryKey(),
chatId: varchar('chat_id', { length: 256 }).notNull(),
contactId: uuid('contact_id').references(() => contacts.id, { onDelete: 'cascade' }),
whatsappId: uuid('whatsapp_id').references(() => whatsapps.id, { onDelete: 'cascade' }).notNull(),
name: varchar('name', { length: 256 }).notNull(),
customName: varchar('custom_name', { length: 256 }),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at'),
}, (table) => [
uniqueIndex('chat_whatsapp_idx').on(table.chatId, table.whatsappId),
]); |
What version of
drizzle-orm
are you using?0.33.0
What version of
drizzle-kit
are you using?0.24.2
Describe the Bug
Creating an index with an operator results in the wrong migration output.
Using
drizzle-kit generate
the generated migration file does not include this:drizzle-kit push
seems to not have this issue. because I get not errors there when trying to push my schema with this index.Expected behavior
drizzle-kit generate
creates the correct index with option.Environment & setup
No response
The text was updated successfully, but these errors were encountered: