generate
Generate a new migration that represents the difference between your current schema and the last recorded state. Each migration includes a forward (up.ts) and a rollback (down.ts) file, so changes can be applied and reverted reliably.
Usage
- npm
- pnpm
- Bun
- Yarn
npm exec durcno generate [--config path/to/durcno.config.ts]
pnpm exec durcno generate [--config path/to/durcno.config.ts]
bunx durcno generate [--config path/to/durcno.config.ts]
yarn durcno generate [--config path/to/durcno.config.ts]
Common options
--config <path>— Path to config file (defaults todurcno.config.ts).
What it produces
After running the command you should see a new folder in your configured out directory (commonly migrations/) that contains:
up.ts— exports DDL statements to apply the migrationdown.ts— exports DDL statements to roll back the migration
Example
- Update your schema in
db/schema.ts(add or change tables/columns). - Run:
- npm
- pnpm
- Bun
- Yarn
npm exec durcno generate
pnpm exec durcno generate
bunx durcno generate
yarn durcno generate
- Review the generated
up.tsanddown.tsin the new migration folder. Edit the generated DDL statements if you need to tweak or add data migrations.
Tips
- Review
up.tsanddown.tscarefully before applying to production. - If a generated migration contains undesired changes, adjust the DDL statements or fix your schema and re-run
generate.
Next: apply the migration with durcno migrate.