DrizzleKit - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like delitions and renames by prompting user input.

How it works?

drizzle-kit will traverse schema folder or schema file, generate schema snapshot and compare it to the previous version(if there's one). Based on the difference it will generate all needed SQL migrations and if there're any automatically unresolvable cases like renames it will prompt user for input.
schema.ts
import { integer, pgTable, serial, text, varchar } from "drizzle-orm-pg";
const users = pgTable("users", {
id: serial("id").primaryKey(),
fullName: varchar("full_name", { length: 256 }),
}, (table) => ({
nameIdx: index("name_idx", table.fullName),
})
);
export const authOtp = pgTable("auth_otp", {
id: serial("id").primaryKey(),
phone: varchar("phone", { length: 256 }),
userId: integer("user_id").references(() => users.id),
});

Installation & configuration

Running with CLI options

Or put your file to `drizzle.config.json` configuration file:

List of commands

Generate SQL migrations based on current .ts schema\

--config [optional defalut=drizzle.config.json] config file path
--schema path to typescript schema file or folder with multiple schema files
--out [optional default=drizzle/] migrations folder

Introspect existing database and generate typescript schema

Update stale snapshots

--out [optional] migrations folder
--config [optional defalut=drizzle.config.json] config file path

Migrations collisions check

--out [optional] migration folder
--config[optional defalut=drizzle.config.json] config file path