如何使用 Laravel 迁移在 Mysql 列中添加评论

How to add comment in Mysql column using Laravel Migrations

这就是我想要做的

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')
            ;
        });
    }

但是迁移中没有显示评论是不是我遗漏了什么?

我也看过这个问题,但它不起作用

你可以这样试试,

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');
    });
}

参考 Link here and here.