How to set a comment on table using Laravel Schema Builder

前端 未结 1 510
忘掉有多难
忘掉有多难 2021-02-07 02:27

How to set a comment on table using Laravel Schema Builder?

Column set:

public function up()
{
    Schema::create(\'vendors\', function (Blueprint $table         


        
相关标签:
1条回答
  • 2021-02-07 02:51

    Well I don't have a nice answer for you, but at least it works.

    Here it is:

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

    Just add a DB statement after creating your table.

    0 讨论(0)
提交回复
热议问题