adding-comment-in-table-via-migration-file-laravel

Adding comment in table via migration file — Laravel

2023-02-09

I'll show you how to add a comment in table via migration file at Laravel project.


Before Laravel 9, we can do this:


// migration file

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->id();});

    // don't forget to call this DB Facade before class migration
    // use Illuminate\Support\Facades\DB;
    DB::statement("ALTER TABLE" `users` comment 'your comment here'");
}

Since Laravel 9, we can do this:

// migration file

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->comment('your comment for table here');
        $table->id();});
}

I hope this helpfull for you.