Laravel 5.2迁移对迁移中的列的评论

时间:2017-06-15 02:21:08

标签: php laravel-5.2

我正在开发一个带有laravel 5.2的项目。我有一个问题,我创建了一个迁移文件来更改列的注释。但根据文档,它表示在添加列时使用“列修饰符”。所以我不知道如何更新现有专栏的评论,有人可以帮助我吗?感谢。

1 个答案:

答案 0 :(得分:2)

您可以使用comment()方法和change()

Schema::table('users', function(Blueprint $table) {
    $table->string('name')->comment('Name of the user')->change();
});

确保正确迁移

mysql> show full columns from users like 'name';
+-------+--------------+--------------------+------+-----+---------+-------+---------------------------------+------------------+
| Field | Type         | Collation          | Null | Key | Default | Extra | Privileges                      | Comment          |
+-------+--------------+--------------------+------+-----+---------+-------+---------------------------------+------------------+
| name  | varchar(255) | utf8mb4_unicode_ci | NO   |     | NULL    |       | select,insert,update,references | Name of the user |
+-------+--------------+--------------------+------+-----+---------+-------+---------------------------------+------------------+
相关问题