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

2022-08-30 17:13:30

这就是我正在努力做的事情

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

但是评论没有显示在迁移中,我在这里错过了什么吗?

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


答案 1

你可以试试这样,

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

参考链接 这里这里.


答案 2

推荐