How to set a table comment using Laravel Schema Builder

How to set a table comment using Laravel Schema Builder?

Column Set:

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

But for the table?

+7
comments schema laravel
source share
2 answers

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

Here he 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 the table.

+13
source share

Comment in database migration schema

When creating a Thats Time migration table, if you need a comment in the coloumn name, you can use.

  Schema::table('users', function (Blueprint $table) { $table->tinyInteger('status')->comment('0 = Inactive, 1 = Active'); }) 

;

-one
source share

All Articles