我正在编写我的第一个 Rails 应用程序.我已经运行了一些 rails generate model ... 和 rake db:migrate 命令,但我现在想更改我的数据模型,因此需要撤消一些迁移.
I'm writing my first Rails app. I've run a few rails generate model ... and rake db:migrate commands, but I now want to change my data model and so need to undo a few migrations.
文档 说我可以使用 rake db 撤消迁移:rollback,但这不起作用.当我在控制台中运行它时,计算机会思考几秒钟,但不会对 db/migrate/ 或 db/migrate/schema.rb 进行任何更改.没有输出打印到控制台.
The docs say I can undo a migration with rake db:rollback, but this isn't working. When I run this in the console the computer thinks for a few seconds but doesn't make any changes to db/migrate/ or db/migrate/schema.rb. No output is printed to the console.
这种行为是否正确?db:rollback 不应该改变我的架构吗?如果是这样,有人能想到为什么它可能不起作用吗?
Is this behavior correct? Shouldn't db:rollback be changing my schema? If so, can anyone think why it might not be working?
我在使用 Rails v. 3.2.6.
I'm on Rails v. 3.2.6.
编辑
目前 rake db:migrate:status 给出
database: db/development.sqlite3 Status Migration ID Migration Name -------------------------------------------------- up 20120617191211 Create irs up 20120701154357 Create paths up 20120701154421 Create nodes up 20120702151447 ********** NO FILE ********** down 20120702155140 Create venues down 20120703233833 Remove path from venues 推荐答案解决方案(见我的评论):运行
Solution (see my comment): run
rake db:migrate:status并纠正您在那里发现的问题.在这种情况下(根据 @MarkThomas 的后续跟进),您可能需要检查您需要的所有文件是否就位.
and correct problems you find there. In this case (per @MarkThomas' followup), you might want to check all files you need are in place.
更多推荐
耙数据库:回滚不起作用?
发布评论