Generate schema migrations
You changed a Drizzle schema and need reproducible SQL changes tracked in a migration directory.
Neon · Const
Drizzle Kit is the CLI companion used with Drizzle ORM to manage schema migrations for a Neon Postgres database. Configure it in drizzle.config.ts, generate migration SQL, and apply those migrations with the CLI.
Drizzle Kit is the migration-focused CLI used alongside Drizzle ORM and Neon. A drizzle.config.ts file defines the schema location, migration output directory, SQL dialect, and database credentials; generated SQL migrations can then be applied to Neon with the migrate command.
npx drizzle-kit migratenpx drizzle-kit migrate.import 'dotenv/config';
import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';
const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql);
console.log('Drizzle client configured for Neon');This initializes a Drizzle ORM client using Neon's serverless HTTP driver; run migrations separately with Drizzle Kit.
You changed a Drizzle schema and need reproducible SQL changes tracked in a migration directory.
A deployment or development database must receive previously generated schema changes.
A project needs migration behavior shared consistently across developers and environments.
Drizzle Kit is installed as a development dependency and is used for database migrations. It reads drizzle.config.ts to locate the schema and determine where migration files should be written.
Follow-up: How are generated migrations applied? Run npx drizzle-kit migrate; the command reads the configuration and applies the generated SQL files to Neon.
The configuration file specifies the schema path, migration output directory, PostgreSQL dialect, and database URL. This separates migration configuration from the application code that creates the Drizzle client.
Follow-up: Why should the schema and output paths be explicit? Drizzle Kit needs them to discover schema changes and know where to create migration files.
Install drizzle-kit with the package manager as a development dependency, then run its CLI through npx. The documented migration workflow uses npx drizzle-kit migrate after the configuration and migration files are ready.
Follow-up: What is the distinction between generating and applying migrations? Generation creates SQL from schema changes; migration executes those SQL changes against Neon.
Drizzle ORMdrizzle.config.ts@neondatabase/serverlessdrizzle-kit generatedrizzle-kit migrate