-2

将数据库从我的应用程序迁移到新服务器后,当我运行命令时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' ..........

有没有人遇到过类似的问题并可以提供帮助?

4

1 回答 1

0

显然你已经有一个专栏type

type在 STI 的 ActiveRecord 中使用...您可以尝试使用不同的列名,例如type_of,看看是否对其进行了排序。

于 2015-02-06T17:41:46.083 回答