sonamu-migration
Database migrations
Sonamu compares the entity definitions under src/application with one database that has every
existing migration applied, then writes Knex migration files under src/migrations. The entity
definition is the target schema; a direct database change that is absent from the entity definition
can appear as a difference on the next generation when it affects the columns, indexes, or FKs that
Sonamu models.
Run migration commands from the API package root: the directory that contains
src/sonamu.config.ts and the package's sonamu script. Do not assume a repository-specific
directory name.
Migration mutations default to a non-writing result; use migrate preview when you need an explicit
apply or rollback plan. Apply a change only with --execute --confirm. Executing migrate apply or
migrate rollback against production also requires --force-reason. Use the sonamu-cli skill
for machine-readable output and the complete approval rules.