当前位置:  开发笔记 > 编程语言 > 正文

如何使用Laravel Schema Builder在表上设置注释

如何解决《如何使用LaravelSchemaBuilder在表上设置注释》经验,为你挑选了1个好方法。

如何使用Laravel Schema Builder在表上设置注释?

列集:

public function up()
{
    Schema::create('vendors', function (Blueprint $table) 
    {
        $table->comment('not working - error'); // not working - error
        $table->increments('id');
        $table->string('vendor', 255)->comment('Some comment.');
        $table->timestamps();
    });
}

但对于桌子?



1> Fabio Antune..:

好吧,我没有给你一个很好的答案,但至少它有效.

这里是:

public function up()
{
    $tableName = 'vendors';

    Schema::create($tableName, function (Blueprint $table) 
    {
        $table->increments('id');
        $table->string('vendor', 255)->comment('Some comment.');
        $table->timestamps();
    });

    DB::statement("ALTER TABLE `$tableName` comment 'My comment'");
}

只需在创建表后添加DB语句即可.

推荐阅读
拾味湖
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有