drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.44k stars 484 forks source link

[BUG]: Index migration query is generated with parameter #2508

Closed alicelepadat closed 2 weeks ago

alicelepadat commented 2 weeks ago

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.7

Describe the Bug

Hello

I defined an index with new version syntax using where:

 systemNameIndex: uniqueIndex('system_name_unique_idx').on(table.name).where(eq(table.type, 'SYSTEM'))

but the migration query is generated with a parameter like this:

CREATE UNIQUE INDEX IF NOT EXISTS "system_name_unique_idx" ON "group" USING btree ("name") WHERE "group"."type" = $1;

The migration fails with: PostgresError: there is no parameter $1

It's annoying because I updated the generated migration with 'SYSTEM' instead of $1, but every time I make other modifications and want to generate a new migration this index is being dropped and then regenerated.

Expected behavior

CREATE UNIQUE INDEX IF NOT EXISTS "system_name_unique_idx" ON "group" USING btree ("name") WHERE "group"."type" = 'SYSTEM';

Environment & setup

Database: postgresql

alicelepadat commented 2 weeks ago

This issue is a duplication of this one