问题
I am very new in cakephp version 3. Here I am trying to use migration plugin. I have already created a table by using below command
=> cake bake migration CreateUsers name : string
It's worked very fine, now I am trying to add a field in here so I have written
=> cake bake migration add age:int to Users
It's not working. How can I add this field by migration using shall command ?May you help me please ?
回答1:
A syntax like
add column:type to table
doesn't exist, so that's why you are seeing what you're seeing. The correct syntax for adding columns is
AddColumnNameToTableName column:type
where the column name between Add
and To
is optional.
ie your command should look something like
bin/cake bake migration AddAgeToUsers age:int
See
- Cookbook > Migrations > Creating Migrations
- https://github.com/cakephp/migrations
来源:https://stackoverflow.com/questions/31628874/how-to-add-a-field-in-database-table-by-cakephp-migration