Skip to content

apply command ​

The apply command executes all SQL statements from the specified file against a target database. This is useful when you've reviewed a generated migration plan and want to run it against your database.

Usage ​

bash
migrata apply --from <SOURCE> --to <TARGET>

Options ​

OptionDescription
--from <SOURCE>Path to the migration plan file to apply. (Required)
--to <TARGET>The target database connection string to execute the SQL statements against. (Required)
--dry-runPreview the changes without executing. Displays all DDL statements that would be applied.
--include / --excludeGlob patterns to include/exclude entities based on their fully qualified name
--silentSuppress SQL parsing error messages.
--no-logsSuppress execution logs and progress output.
--skip-lockDisable advisory locking during migrations (unsafe for concurrent runs).
--log-fileOptional file to write execution logs to.

Examples ​

Preview the changes from a generated migration plan:

bash
migrata apply \
  --from ./migrations/1740612345_add_users_table.sql \
  --to "postgresql://user:pass@host:5432/mydb" \
  --dry-run

Apply a migration plan:

bash
migrata apply \
  --from ./migrations/1740612345_add_users_table.sql \
  --to "postgresql://user:pass@host:5432/mydb"