Appearance
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
| Option | Description |
|---|---|
--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-run | Preview the changes without executing. Displays all DDL statements that would be applied. |
--include / --exclude | Glob patterns to include/exclude entities based on their fully qualified name |
--silent | Suppress SQL parsing error messages. |
--no-logs | Suppress execution logs and progress output. |
--skip-lock | Disable advisory locking during migrations (unsafe for concurrent runs). |
--log-file | Optional 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-runApply a migration plan:
bash
migrata apply \
--from ./migrations/1740612345_add_users_table.sql \
--to "postgresql://user:pass@host:5432/mydb"