drizzle-team / drizzle-team/drizzle-orm

[BUG]: `drizzle-kit pull` - Composite Index Operator Classes in Wrong Order

Open
#5,056 1 comment 0 reactions 0 assignees View on GitHub
bug bug/fixed-in-beta
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] 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.44.7

### What version of `drizzle-kit` are you using?

0.31.7

### Other packages

_No response_

### Describe the Bug
**Database: postgres:17.5**

When I run `drizzle-kit pull`, in the generated migration file, the statement defining composite index's have the wrong operator order.

For example, here is what `drizzle-kit` produced:
```
CREATE INDEX "idx_responses_prompt_created" ON "responses" USING btree ("prompt_id" timestamptz_ops,"created_at" uuid_ops);
```
Here is the definition from the database:
```
CREATE INDEX idx_responses_prompt_created ON public.responses USING btree (prompt_id, created_at DESC);
```

To reproduce, run `drizzle-kit pull` on a database with composite indices of different types. This isn't restricted to the those types either, `text_ops` and `uuid_ops` have also been swapped. Some indices are actually correct while others are wrong, but the ones that are correct/wrong are consistent over multiple runs of `drizzle-kit pull`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.