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]: `drizzle-kit introspect` produces diffs without underlying schema changes #2530

Open brittlewis12 opened 1 week ago

brittlewis12 commented 1 week ago

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:

actual behavior

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:

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,
  },
});