Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amitt's avatar

How to rollback a specific batch

How can I rollback a specific batch from the migration? I created a column in a previous batch and I want to drop only that column without dropping all batched after that. Is there an official way to do it?

I know that I can just altering the batch number to the last batch and than use migrate:rollback and deleting the file + the row in the migration table. but the question is if it's an official way?

0 likes
2 replies
michaeldyrynda's avatar
Level 41

There's no specific way to do it with migrations.

There's a couple of options, though:

  1. If you haven't shared the migrations with anyone and the code isn't in production, just rollback the migrations and edit the original one with your new definition
  2. Create a new migration to change the existing column. you'll need to composer require doctrine/dbal for this to work... unless that table has an enum field in it, in which case you'll need to write ALTER statements manually.
bobbybouwmann's avatar

This is why you have the up and down function in your migrations. So you can roll them back and add them in later as well

public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->integer('active')->default(0);
    });
}

public function down()
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropColumn('active');
    }
}

When you run php artisan migrate the column will be added. When you run php artisan migrate:rollback it will remove the column for you. This way you can always rollback!

Please or to participate in this conversation.