How to add several columns to a database in Rails

天涯浪子 提交于 2020-01-03 15:21:06

问题


Hi I just created a database in RoR. I now want to add 10 more columns to it. However, I dont want to use the following type of command that adds only 1 column at a time:

rails generate migration AddClosing_Hrs1ToBusinesses closing_hrs1:string

Is there a way to add multiple columns to my database without having to type a command for each column individually like above?


回答1:


You can specify your column names all in one go

rails generate migration AddClosing_Hrs1ToBusinesses closing_hrs1:string new_cloumn:string third_column:string

Documentation : http://guides.rubyonrails.org/migrations.html



来源:https://stackoverflow.com/questions/9550181/how-to-add-several-columns-to-a-database-in-rails

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