Master drizzle-kit generate, push, migrate(), introspect, and drizzle.config.ts for type-safe SQL migration workflows
0 / 5 completed
1 / 5
What does drizzle-kit generate produce?
drizzle-kit generate: compares the current TypeScript schema with the last stored snapshot in the meta folder and emits a numbered SQL migration plus an updated snapshot. The SQL is committed to source control, giving a reviewable, deterministic migration history rather than relying on runtime auto-syncing.
2 / 5
How does drizzle-kit push differ from generate + migrate?
drizzle-kit push: introspects the live database, computes the diff against your schema, and applies DDL directly — no migration file is written. This is ideal for rapid local prototyping. For production you typically prefer generate + migrate so each change is a committed, auditable artefact with a clear rollback story.
3 / 5
What is the purpose of the migrate() function from drizzle-orm/migrator?
migrate():await migrate(db, { migrationsFolder: './drizzle' }) applies any not-yet-run SQL files in order, recording each in an internal tracking table (e.g. __drizzle_migrations). It is idempotent: running it again only applies new files. This is the deploy-time counterpart to generate.
4 / 5
What does drizzle-kit introspect (pull) do?
introspect / pull: connects to an existing database, reads its tables, columns, and constraints, and produces a schema.ts describing them in Drizzle's syntax, along with a snapshot. This lets teams adopt Drizzle incrementally on a database that already exists rather than redefining the schema by hand.
5 / 5
What is configured in drizzle.config.ts?
drizzle.config.ts: exported via defineConfig, it specifies schema (path to your table definitions), dialect (e.g. postgresql), out (migrations folder), and dbCredentials. drizzle-kit reads this file for every command, so generate, push, migrate, and studio all share one configuration source.