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

Syntax

Basic Usage

Rollback the last migration batch:
Output:

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

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

See Also

migrate

Run pending migrations

migrate:status

Check migration status

make:migration

Create new migrations

Migration API

Migration class reference