Home » Php » php – How to add comment in Mysql column using Laravel Migrations

php – How to add comment in Mysql column using Laravel Migrations

Posted by: admin July 12, 2020 Leave a comment

Questions:

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

How to&Answers:

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.