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

rijans's avatar

Migration to Add Comment to Existing Column

I have a column as tinyInteger. Now I would like to add comment to the column with new migration file.

public function up() { Schema::table('sales_invoices', function (Blueprint $table) { $table->tinyInteger('invoice_type')->comment('0 > A Normal Invoice, 1 > A Recurring Invoice'); }); }

Now above is the code I am trying in new schema to add comment, but it doesn't work and gives error.

0 likes
3 replies
D9705996's avatar
D9705996
Best Answer
Level 51

You need to use the change function

public function up() {
  Schema::table('sales_invoices', function (Blueprint $table) { 
    $table->tinyInteger('invoice_type')
        ->comment('0 > A Normal Invoice, 1 > A Recurring Invoice')
        ->change();
  }); 
}

There are some caveats to using this and you will need to run composer require doctrine/dbal

https://laravel.com/docs/5.7/migrations#modifying-columns

1 like

Please or to participate in this conversation.