phplaravel-5artisan-migrate

Artisan change column comments with name in dash


I want to change a columns comment in MySQL table with Laravel.

However, I get an error when migrating.

"Syntax error (SQL: ALTER TABLE category CHANGE zh-TW zh-TW VARCHAR(191) 
NOT NULL COMMENT 'Name in Chinese')".

Code as follow:

Schema::table('category', function (Blueprint $table) {
    $table->string('zh-TW')->comment('Name in Chinese')->change();
});

Solution

  • Finally, I use code as below

    `DB::statement("ALTER TABLE category CHANGE `zh-TW` `zh-TW` VARCHAR(191) NOT NULL comment 'Name in Chinese';");