Rup*_*ott 11 migration ruby-on-rails-3
如果我创建一个表rails generate migration,我可以稍后通过创建一个新的迁移添加一个额外的列.我还可以回滚原始迁移,然后编辑它以包含额外列.
//Create the model including the migration
$ rails generate model Foo bar:string
//Perform the migration
$ rake db:migrate
//Create the add column migration
$ rails generate migration add_foobar_to_foos foobar:string
//Perform the new migration
$ rake db:migrate
Run Code Online (Sandbox Code Playgroud)
//Create the model including the migration
$ rails generate model Foo bar:string
//Perform the migration
$ rake db:migrate
//Rollback the migration
$ rake db:rollback
//Edit the original migration file
//Perform the new migration
$ rake db:migrate
Run Code Online (Sandbox Code Playgroud)
完成此任务的正确/最佳方法是什么?为什么?
dda*_*yan 13
生病的方法1.为什么?因为如果其他开发人员/机器正在使用此环境,您可能会因为他们可能需要在正确的时间回滚以维护正确的数据库结构而获得不稳定的状态.
| 归档时间: |
|
| 查看次数: |
8774 次 |
| 最近记录: |