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

こ雲淡風輕ζ 提交于 2019-12-07 13:34:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!