内容简介:翻译自:https://stackoverflow.com/questions/7453981/devise-rake-dbmigrate-fails-because-of-duplicate-column-in-my-users-table-ra
这是我第一次安装Devise并运行rake db:migrate时遇到的错误:
== AddDeviseToUsers: 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
鉴于这只是测试数据,我可以删除我的数据库中的那个列并重新运行它,但这似乎不是Railsy – 如果只是因为它将使我的登台服务器(唯一的其他服务器与我的应用程序与我的localhost不同步.
此外,如果与另一列发生冲突,该怎么办?
因此,在运行迁移之前,这是我的User表的架构,我该如何处理?迁移某种重命名的迁移?
# == Schema Information # # Table name: users # # id :integer not null, primary key # email :string(255) # f_name :string(255) # l_name :string(255) # username :string(255) # role_id :integer # picture :string(255) # about_me :string(255) # website :string(255) # created_at :datetime # updated_at :datetime #
class CreateProducts < ActiveRecord::Migration
def up
create_table :products do |t|
t.string :email
t.text :f_name
t.timestamps
end
end
def down
drop_table :products
end
end
您可以在这里获得更多信息 http://guides.rubyonrails.org/migrations.html
翻译自:https://stackoverflow.com/questions/7453981/devise-rake-dbmigrate-fails-because-of-duplicate-column-in-my-users-table-ra
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Beginning XML with DOM and Ajax
Sas Jacobs / Apress / 2006-06-05 / USD 39.99
Don't waste time on 1,000-page tomes full of syntax; this book is all you need to get ahead in XML development. Renowned web developer Sas Jacobs presents an essential guide to XML. Beginning XML with......一起来看看 《Beginning XML with DOM and Ajax》 这本书的介绍吧!