Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add comment in Mysql column using Laravel Migrations

Tags:

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

like image 251
Romantic Dev Avatar asked Mar 13 '18 12:03

Romantic Dev


People also ask

How do I add a column to an existing migration in Laravel?

The Laravel migrations will use the Schema facade to create and modify database tables and columns: Schema::create('tasks', function (Blueprint $table) { $table->bigIncrements('id'); $table->timestamps(); }); Inside the facade, you could specify the different columns that you want to add.


1 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 and here.

like image 112
Rahul Avatar answered Oct 05 '22 18:10

Rahul