如何通过 cakephp 迁移在数据库 table 中添加一个字段?

How to add a field in database table by cakephp migration?

我是 cakephp 版本 3 的新手。我在这里尝试使用迁移插件。我已经使用下面的命令

创建了一个 table
=> cake bake migration CreateUsers name : string 

它工作得很好,现在我想在这里添加一个字段所以我写了

=> cake bake migration add age:int to Users 

它不起作用。我怎样才能使用 shall 命令通过迁移添加这个字段?你能帮我吗?

类似

的语法
add column:type to table

不存在,所以这就是为什么你看到你所看到的。添加列的正确语法是

AddColumnNameToTableName column:type

其中 AddTo 之间的列名是可选的。

即您的命令应该类似于

bin/cake bake migration AddAgeToUsers age:int