27

This is what I am trying to do

if (!Schema::hasColumn('account_settings', 'minimum_onsite_length')) {
        Schema::table('account_settings', function (Blueprint $table) {
            $table->unsignedInteger('minimum_onsite_length')
                ->default(180)
                ->nullable()
                ->comment('This is comments')
            ;
        });
    }

But comments are not showing in migration is there any thing I am missing here?

I have also looked to this question but it is not working here

Rahul
  • 18,271
  • 7
  • 41
  • 60
FULL STACK DEV
  • 15,207
  • 5
  • 46
  • 66

1 Answers1

30

You can try like this,

if (!Schema::hasColumn('account_settings', 'minimum_onsite_length')) {
    Schema::table('account_settings', function (Blueprint $table) {
        $table->unsignedInteger('minimum_onsite_length')
            ->default(180)
            ->nullable()
            ->comment('This is comment');
    });
}

Ref Link here and here.

Arda
  • 6,756
  • 3
  • 47
  • 67
Rahul
  • 18,271
  • 7
  • 41
  • 60
  • 3
    According to official document of Laravel 5.7, comment can be added by "->comment('my comment')". https://laravel.com/docs/5.7/migrations – Kamlesh Jan 31 '19 at 18:14
  • 1
    Can confirm that, `->comment('my comment');` also works on Laravel 4.2. – Arda Mar 04 '19 at 09:06
  • 2
    I can confirm `->comment('my comment')` does work till date up to 7.x. More on official documentation https://laravel.com/docs/7.x/migrations#column-modifiers – Hashmat Jul 04 '20 at 04:03