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
23.52k stars 576 forks source link

[BUG]: introspect creates `schema.ts` within `out` dir, not at schema path in `drizzle.config.ts` #1360

Open jasongitmail opened 11 months ago

jasongitmail commented 11 months ago

What version of drizzle-orm are you using?

0.28.6

What version of drizzle-kit are you using?

0.19.13

Describe the Bug

  1. Given drizzle.config.ts:
import { Config } from 'drizzle-kit';

export default {
  dbCredentials: {
    authToken: process.env.TURSO_DB_AUTH_TOKEN as string,
    url: process.env.TURSO_DB_URL as string,
  },
  driver: 'turso',
  out: './drizzle/migrations', // <<<
  schema: './drizzle/schema.ts', // <<<
  strict: true,
  verbose: true,
} satisfies Config;
  1. Run npm run migration:introspect, which uses "migration:introspect": "drizzle-kit introspect:sqlite",.

Behavior

Expected behavior

No response

Environment & setup

No response

jasongitmail commented 11 months ago

Further, with this setup I've found that running "migration:generate": "drizzle-kit generate:sqlite", will not look for schema at the path specified in drizzle.config.ts (i.e. at ./drizzle/schema.ts in my case) and consequently will generate a migration to create ALL new tables as if they don't exist yet.

But I can resolve this by moving my schema.ts into the migrations dir, or switching back to the directory structure (below) to get fully expected behavior:

  // drizzle.config.ts
  ...
  out: './drizzle',
  schema: './drizzle/schema.ts',
  ...

Though it'd be nice to have all the migration files hidden away inside a migrations dir.