如何使用Laravel Migrations在Mysql列中添加注释

时间:2018-03-13 12:20:45

标签: php laravel eloquent laravel-5.3

这就是我想要做的事情

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

但是迁移中没有显示评论我在这里缺少什么东西?

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

1 个答案:

答案 0 :(得分:5)

你可以这样试试,

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

参考链接here