我希望在我的"用户"中更加具体。表。我创建了一个名为" location"然后意识到我想要"陈述"和"城市"代替。位置迁移很好但是当我更改名称时,我意外地将类型更改为状态而不是名称。好吧,我想我会运行一个新的迁移并将类型更改回文本,然后重命名该列。那是我遇到一些错误的地方。我目前在终端
中收到此信息undefined method `to_sym' for nil:NilClass/usr/local/rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/schema_definitions.rb:216:in `column'
迁移状态
Status Migration ID Migration Name
--------------------------------------------------
up 20140710145422 Devise create users
up 20140710145425 Add name to users
up 20140710145432 Add role to users
up 20140710201635 Create books
up 20140710204116 Create pits
up 20140715181941 Add author to books
up 20140729005134 Fix column name
up 20140729005452 Add columnto users
up 20140730031957 Add topic to pit
up 20140730032046 Add image to pit
up 20140730032123 Add video to pit
up 20140730204604 Add summary to pits
up 20140810150735 Add author to pits
up 20140810192646 Add about to users
up 20140811060108 Create comments
up 20140811184800 Add column to pits
up 20140819182243 Acts as votable migration
up 20140822173255 Add location to users
up 20140822181121 Change user location
down 20140822181813 Change location field
最后三个迁移文件
class AddLocationToUsers < ActiveRecord::Migration
def change
add_column :users, :location, :string
end
end
class ChangeUserLocation < ActiveRecord::Migration
def change
change_column :users, :location, :state
end
end
class ChangeLocationField < ActiveRecord::Migration
def change
change_column :users, :location, :string
end
end
我尝试了rake db:rollback,甚至尝试删除并重新创建数据库,该数据库提供了与上面相同的错误。如果这有所不同,我也会使用设计。我基本上什么都做不了而且我被卡住了。我只是想改变位置&#34;输入&#34;发送文本并将事后的该列重命名为&#34; city&#34;。使用SQlite。在这里会有一些帮助。感谢
答案 0 :(得分:1)
因此,在我通过rake db:migrate VERSION = XXXXXXXXXXXX导致问题的迁移之前恢复到旧的迁移时,解决了这个问题。这篇帖子的道具