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

Benko's avatar
Level 6

Update an existing column in an existing table in Laravel migration?

Is there a way to update a column in a Laravel migration? For example, I have a body column in the reviews table, and I would like to make it nullable (preferably without having to re-migrate everything), but I'm not sure how to do it. Is it like adding a new column to an existing table?

I only found a tutorial online on how to change a table name via migration.

0 likes
2 replies
MichalOravec's avatar
Level 75

Make new migration with

php artisan make:migration change_body_to_nullable_in_reviews_table --table=reviews

where you put this

public function up()
{
    Schema::table('reviews', function (Blueprint $table) {
        $table->text('body')->nullable()->change();
    });
}

public function down()
{
    Schema::table('reviews', function (Blueprint $table) {
        $table->text('body')->nullable(false)->change();
    });
}

And then run php artisan migrate

10 likes
Benko's avatar
Level 6

Thanks! It worked. I just needed to install a few dependencies via: composer require doctrine/dbal

2 likes

Please or to participate in this conversation.