【发布时间】:2011-05-09 17:25:47
【问题描述】:
我正在从 Authlogic 迁移到 Devise。
更新:
设计的迁移尝试重新创建表用户,所以我将 create_table 更改为 change_table 并在最后删除表以删除我添加的内容
问题是当我运行 rake 时出现错误。
这是我在运行 rake 时遇到的错误。
== 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 的答案标记为正确。否则,此问题将出现在“未回答的问题列表”中。
标签: ruby-on-rails