2011-06-01 119 views
1

我有一個遷移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                                                                                   
+0

沒有錯誤?哪個版本的rails是這個? – corroded 2011-06-01 10:06:42

回答

3

這應該是個訣竅。我想你給你的表命名爲token_authenticatable,然後嘗試刪除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