繁体   English   中英

为什么迁移不起作用

[英]Why migration doesn't work

我有一个迁移 AddAuthenticableToUser。 (rake db:migrate:up VERSION=..) 工作正常,但是当我尝试回滚迁移时 (rake db:migrate:down VERSION=..) 它不起作用。 任何错误或警告。 你能帮我解决这个问题吗?

def self.up
  change_table :users do |t|
    t.token_authenticatable
  end
  add_index :users, :authentication_token, :unique => true
end

def self.down
  remove_index :users, :authentication_token                                                                                                                      
  remove_column :users, :authentication_token
end                                                                                                                                                                                                                                                                                                                                         

这应该是诀窍。 我认为您将表命名为 token_authenticable,然后尝试删除 authentication_token。

def self.up
  create_table :reviews do |t|
    t.column :authentication_token
  end
  add_index :users, :authentication_token, :unique => true
end

def self.down
  remove_index :users, :authentication_token                                                                                                                      
  remove_column :users, :authentication_token
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM