如何使用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(); }); }
但对于桌子?
好吧,我没有给你一个很好的答案,但至少它有效.
这里是:
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语句即可.