Skip to content

Commands

Quick reference

Command Arguments Options Purpose
init --force Generate default config
init:mysql --force Generate MySQL defaults
init:pgsql --force Generate PostgreSQL defaults
init:sqlite --force Generate SQLite defaults
make <name> --sql, --populate Create a migration
migrate / up --dry-run, --pretend Run pending migrations
rollback / down --dry-run, --pretend Roll back last batch
reset --dry-run, --pretend Roll back all migrations
refresh --dry-run, --pretend Roll back and rerun
fresh Rebuild from a clean schema
status Show migration status
validate Validate migration files
doctor Check environment/config
repair --modified, --force Repair repository records
squash [name] --force Create a schema baseline
unsquash [archive] --force Restore pre-squash history
help Show CLI help

init

php vendor/bin/migraw init

Driver-specific defaults:

php vendor/bin/migraw init:mysql
php vendor/bin/migraw init:pgsql
php vendor/bin/migraw init:sqlite

Overwrite an existing generated config:

php vendor/bin/migraw init:mysql --force

make

php vendor/bin/migraw make create_users_table

Argument

Argument Required Description
name Yes Migration name used for template detection and filename

Options

Option Description
--sql Force a blank raw SQL migration
--populate Create a PopulatorMigration

Examples:

php vendor/bin/migraw make add_phone_to_users
php vendor/bin/migraw make custom_database_change --sql
php vendor/bin/migraw make populate_roles --populate

--sql and --populate cannot be used together.

migrate / up

Run pending migrations:

php vendor/bin/migraw migrate

Alias:

php vendor/bin/migraw up

Preview without executing:

php vendor/bin/migraw migrate --dry-run

or:

php vendor/bin/migraw migrate --pretend

rollback / down

Roll back the latest batch:

php vendor/bin/migraw rollback

Alias:

php vendor/bin/migraw down

Preview:

php vendor/bin/migraw rollback --dry-run

reset

Roll back all managed migrations:

php vendor/bin/migraw reset

Preview:

php vendor/bin/migraw reset --pretend

refresh

Roll back all managed migrations and execute them again:

php vendor/bin/migraw refresh

Preview:

php vendor/bin/migraw refresh --dry-run

fresh

Rebuild from a clean schema:

php vendor/bin/migraw fresh

Use this when you intentionally want a clean database rebuilt from the active migrations.

status

php vendor/bin/migraw status

Typical states include:

[ran]
[pending]
[ran modified]
[missing]

validate

php vendor/bin/migraw validate

Checks migration files and verifies that migration methods return supported statement types.

doctor

php vendor/bin/migraw doctor

Checks common setup problems such as:

  • config file
  • configured bootstrap
  • database connection
  • PDO driver
  • migrations path
  • migration repository

repair

Remove migration records whose files are missing:

php vendor/bin/migraw repair

Accept current checksums of intentionally modified migrations:

php vendor/bin/migraw repair --modified

Skip confirmation:

php vendor/bin/migraw repair --modified --force

repair --modified updates the repository checksum. It does not rerun the migration.

squash

php vendor/bin/migraw squash

Custom baseline name:

php vendor/bin/migraw squash app_schema

Skip confirmation:

php vendor/bin/migraw squash app_schema --force

See Squash & Unsquash.

unsquash

Restore the latest squash history:

php vendor/bin/migraw unsquash

Select an archive:

php vendor/bin/migraw unsquash 20260826_010000

Skip confirmation:

php vendor/bin/migraw unsquash 20260826_010000 --force

Unsquash restores migration history and files. It does not roll back the current database schema.

help

php vendor/bin/migraw help