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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49256069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:30:20  来源:igfitidea点击:

How to add comment in Mysql column using Laravel Migrations

phplaraveleloquentlaravel-5.3

提问by Adnan Mumtaz

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

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

回答by Rahul

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.

参考链接在这里