Skip to main content
The Migration tab compares Entity definitions with database schemas, creates migration files, and applies migrations to one or more databases.

Compare and generate

The baseline DB selector only includes connections where every migration is applied. Sonamu compares that databaseโ€™s schema with the Entity definitions and previews the changes and generated code.
  1. Select a baseline database.
  2. Expand generated code with the button beside a file, or use Expand all to review every file.
  3. Select Generate migrations to create the files.
After files are generated, Pending state is refreshed for every database.

Migration status

Rows are migration files and columns are database connections. Each cell shows APPLIED or PENDING. Connections load independently, so a slow or failed database does not block other columns.
Sonamu UI only shows and runs the development, test, and fixture connections. The UI API rejects staging and production, so run those migrations with the sonamu migrate CLI.
  • Select an execution target by clicking its column header or cells.
  • Enable Details to show the host, database, remote marker, and per-column refresh action.
  • Select an Error badge to inspect the server error.
  • The first button beside a file expands its code on the page. The second opens the file in VS Code, Cursor, or Zed.

Apply latest

Apply latest runs knex.migrate.latest() for each selected database in order. Files applied to one database remain in one Knex batch. The execution dialog has these stages:
  1. Review the targets and Pending files, and choose whether to run Shadow validation.
  2. Approval requests Slack approval for configured remote targets and checks it every two seconds.
  3. Apply displays per-file progress and per-database completion.
When Shadow validation is enabled, a dotted Shadow card is shown at the top of the target list. Once Apply starts, the same card shows real validation progress and its result. Sonamu only starts the target databases after Shadow succeeds.
A file-level executed state means that migration function returned. The batch is only final after the database card completes.
If the browser connection drops, a migration already started on the server may continue. Do not run it again automatically; refresh connection status to verify the result.

Rollback

Rollback ignores migration-file row selection and rolls back the entire latest Knex batch on each selected database. Knex runs the batchโ€™s down() functions in reverse order. Because this is destructive, the first click only arms the Rollback button and changes its confirmation text. The second click starts the operation. If a file fails, execution stops at that file. The rollback transaction is canceled, so the database may appear unchanged. Rollbacks run from the latest migration backward, so execution cannot continue to the next rollback after a failure in the middle. When the selection includes a remote database that requires Slack approval, Rollback requests approval first, just like Apply. The request includes each targetโ€™s latest batch number, so an Apply approval or an approval for an earlier batch cannot start a rollback.
Rollback can drop columns or tables and lose data. Verify backups and each down() implementation before running it.

Next steps

Scaffolding Tab

Generate Model code

migrate CLI

Manage migrations from the CLI