drizzle-team / drizzle-team/drizzle-orm

[BUG]: `drizzle-kit introspect` produces diffs without underlying schema changes

Open
#2,530 2 comments 12 reactions 0 assignees View on GitHub
drizzle/kit improvement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

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

0.31.1

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

0.22.2

### Describe the Bug

1. without making changes to the db schema, run `drizzle-kit introspect`.

expected behavior:
- no diff in generated `schema.ts` or `relations.ts` files

actual behavior
- relations & table definitions are reordered arbitrarily each time the command is run.

### Expected behavior

schema & relations definitions should be defined one of alphabetical, creation, or dependency order.

said differently, I expect `drizzle-kit introspect` to be idempotent. for any single given input schema, the generated output should be identical, no matter how many times the command is run.

I do not have a strong preference or intuition behind one or the other, but alphabetical is easy to reason about verify at a glance.

https://github.com/drizzle-team/drizzle-orm/issues/1306 appears loosely related, but materially distinct enough that I wanted to raise a dedicated issue. please feel free to recategorize as you wish.

### Environment & setup

running Bun 1.1.13 on macOS 14.5, connecting to a postgres 16 db through Neon's serverless client.

here's our `drizzle.config.js`:
```js
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dialect: "postgresql",
introspect: {
casing: "camel",
},
schema: "./src/schema.ts",
out: "./drizzle",
dbCredentials: {
url: process.env.DATABASE_URL,
},
});
```

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.