[英]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.