Skip to main content
The migrate:rollback command reverts the last batch of database migrations that were run.

Syntax

php rawr migrate:rollback

Basic Usage

Rollback the last migration batch:
php rawr migrate:rollback
Output:
Rolling back...
Rolled back: 2026_03_08_143045_create_products_table
Rolled back: 2026_03_08_143022_create_users_table
Rollback complete!

How It Works

The rollback command:
  1. Reads Migration History - Queries the migrations table to find the last batch number
  2. Runs Down Methods - Executes the down() method of each migration in reverse order
  3. Removes Records - Deletes the migration records from the migrations table
Rollback operations are destructive and will drop tables and delete data. Always backup your database before rolling back migrations in production.

Migration Batches

Migrations are organized into batches. Each time you run php rawr migrate, all pending migrations are executed as a single batch. The migrate:rollback command reverts one batch at a time.

Example

# Run migrations (batch 1)
php rawr migrate

# Add more migrations
php rawr make:migration create_orders_table

# Run new migrations (batch 2)
php rawr migrate

# Rollback batch 2 only
php rawr migrate:rollback

Use Cases

Development Testing

Test your down() migration methods during development

Fix Migration Errors

Rollback and fix migrations that were deployed with errors

Database Reset

Combined with migrate, reset your database to a clean state

Schema Changes

Revert schema changes that cause issues

Best Practices

  • Always implement down() methods - Ensure all migrations can be rolled back
  • Test rollbacks locally - Verify your down() methods work before deploying
  • Backup production data - Always backup before rolling back in production
  • Use version control - Track migration files in git to coordinate with team

Common Workflow

# Create a new migration
php rawr make:migration add_status_to_users

# Run the migration
php rawr migrate

# Oops, there's an issue - rollback
php rawr migrate:rollback

# Fix the migration file, then re-run
php rawr migrate

See Also

migrate

Run pending migrations

migrate:status

Check migration status

make:migration

Create new migrations

Migration API

Migration class reference