我正在從Authlogic遷移到Devise。在現有模型上設計遷移
更新:
色器件的遷移嘗試重新創建表的用戶,所以我改變了,你可以看到下面的CREATE_TABLE到change_table,並在年底下降表中刪除我添加
問題是當我運行耙子時出現錯誤。
這是運行耙機時得到的錯誤。
== DeviseCreateUsers: migrating ==============================================
-- change_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email" varchar(255) DEFAULT '' NOT NULL
這是遷移
class DeviseCreateUsers < ActiveRecord::Migration
def self.up
change_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
# add_index :users, :confirmation_token, :unique => true
# add_index :users, :unlock_token, :unique => true
end
def self.down
remove_column :users, :database_authenticatable
remove_column :users, :recoverable
remove_column :users, :rememberable
remove_column :users, :trackable
remove_index :users, :email
remove_index :users, :reset_password_token
end
end
在我schema.rb我已經從Authlogic有這個。
create_table "users", :force => true do |t|
t.string "username"
t.string "email"
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
我認爲它看到某種衝突的,我是不能夠認識到如何避免與這些設計助手
謝謝!
請將jamuraa的答案標爲正確。否則,這個問題出現在「未回答的問題列表」中。 – kikito 2012-03-30 18:57:16