从我的应用程序迁移数据库到新服务器后,当我运行命令RAILS_ENV = production rake db: migrate
时,出现以下错误:
== AggregatedGlobalRolesMigrations: migrating ================================
-- add_column(:roles, :type, :string, {:limit=>30, :default=>"Role"})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Duplicate column name 'type': ALTER TABLE `roles` ADD `type` varchar(30) DEFAULT 'Role'/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activesupport-3.2.21/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/mysql2_adapter.rb:213:in `execute'
/home/openproject/.rvm/gems/ruby-2.1.4/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:461:in `add_column' ..........
有没有人遇到类似问题并可以提供帮助?
答案 0 :(得分:0)
显然,您已经有了一列type
type
在ActiveRecord中用于STI ...您可以尝试使用其他列名称,例如type_of
,并查看是否对其进行排序。