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]: drizzle-kit generate ignores index operators #2935

Open
NehrDani opened this issue Sep 9, 2024 · 1 comment
Open

[BUG]: drizzle-kit generate ignores index operators #2935

NehrDani opened this issue Sep 9, 2024 · 1 comment
Assignees
Labels

Comments

@NehrDani
Copy link

NehrDani commented Sep 9, 2024

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.

export const users = pgTable(
  'users',
  {
    id: uuid('id').primaryKey().defaultRandom(),
    name: text('name').notNull(),
  },
  (table) => ({
    nameIdx: index().using('gin', table.name.op('gin_trgm_ops')),
  })
)

Using drizzle-kit generate the generated migration file does not include this:

CREATE INDEX IF NOT EXISTS "users_name_index" ON "users" USING gin ("name");

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.

CREATE INDEX IF NOT EXISTS "users_name_index" ON "users" USING gin ("name" gin_trgm_ops);

Environment & setup

No response

@NehrDani NehrDani added the bug Something isn't working label Sep 9, 2024
@pavelsvitek
Copy link

Maybe this will help. I have a column metadata: jsonb() and I needed to create index for specific field email

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 sql.raw(...) syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants