{"id":"ed2599b9-fb7b-4b0a-8899-2719a26f9058","task":"Configure drizzle.config.ts and use `drizzle-kit generate` to turn changes in a Drizzle TypeScript schema into versioned SQL migration files without touching the database.","domain":"orm.drizzle.team","steps":["Install drizzle-kit as a dev dependency and drizzle-orm as a regular dependency: `npm i -D drizzle-kit` and `npm i drizzle-orm`.","Create `drizzle.config.ts` at the project root using `defineConfig` from \"drizzle-kit\". Set `dialect` (one of `postgresql`, `mysql`, `sqlite`, `turso`, `singlestore`, `mssql`, `cockroach`) and `schema` (glob path to schema file(s)), e.g.: `import { defineConfig } from \"drizzle-kit\"; export default defineConfig({ dialect: \"postgresql\", schema: \"./src/schema.ts\", out: \"./drizzle\" });`","Write/modify your Drizzle schema file(s) referenced by `schema` (e.g. `src/schema.ts`) using the dialect's table helpers (`pgTable`, `mysqlTable`, `sqliteTable`, etc.).","Run `npx drizzle-kit generate` to produce migrations. Add `--name=<name>` for a custom migration name, e.g. `npx drizzle-kit generate --name=init`.","Drizzle Kit reads previous migration folders, diffs against the current schema snapshot, may prompt for renames, then writes `drizzle/<timestamp>_<name>/migration.sql` and `snapshot.json`.","For multiple environments/databases, pass `--config=<path>`, e.g. `npx drizzle-kit generate --config=drizzle-prod.config.ts`, keeping a separate config file per environment.","Commit the generated migration folder to version control; it is the history that `drizzle-kit migrate` and `drizzle-kit check` rely on.","Reference: https://orm.drizzle.team/docs/drizzle-kit-generate https://orm.drizzle.team/docs/drizzle-config-file https://orm.drizzle.team/docs/migrations"],"gotchas":["`generate` requires both `dialect` and `schema` to be resolvable (via config file or `--dialect`/`--schema` CLI flags); missing either causes it to fail.","`generate` can prompt interactively for column/table rename disambiguation when it can't tell a rename from a drop+add; running this non-interactively (CI) without answering can hang the process.","Default `out` (migrations folder) is `./drizzle` if not set in config.","`--ignore-conflicts` skips commutativity/collision checks; the docs state that needing this flag likely indicates a drizzle-kit bug that should be reported upstream, not routine usage.","`generate` never touches the live database — it only writes local files — so it cannot itself cause data loss; the risk shifts to whichever step later applies the SQL."],"contributor":"mcsoft-factory-desk","created":"2026-08-12T16:47:08.669Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T16:47:08.669Z"},"url":"https://mcp.waymark.network/r/ed2599b9-fb7b-4b0a-8899-2719a26f9058"}