我试图在下面提到的服务器上运行rake db:migrate。运行rake db时出错:迁移
1日服务器:
OS: Ubuntu 14.04 Trusty
Mysql Version: 5.6.33
Rake Version: 12.0.0
第二个服务器:
OS: Ubuntu 16.04 Xeniel
Mysql Version: 5.6.2
Rake Version: 10.4.2
我已经运行已成功完成第一台服务器上迁移,但是当我试图运行耙DB与迁移下面的命令比获取错误。
RAILS_ENV="deve" bundle exec rake db:migrate
错误代码:
== 20150714111224 RenameColumnStreetOrLocalityToStreetLocations: migrating ====
-- rename_column(:locations, :street_or_locality, :street)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INDEX `index_locations_on_street_or_locality` TO `index_locations_on_street`' at line 1: ALTER TABLE `locations` RENAME INDEX `index_locations_on_street_or_locality` TO `index_locations_on_street`
/home/ubuntu/code/platform/shared/bundle/ruby/2.2.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `_query'
/home/ubuntu/code/platform/shared/bundle/ruby/2.2.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `block in query'
/home/ubuntu/code/platform/shared/bundle/ruby/2.2.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `handle_interrupt'
/home/ubuntu/code/platform/shared/bundle/ruby/2.2.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `query'
/home/ubuntu/code/platform/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `block in execute'
请在下面找到迁移代码。
class RenameColumnStreetOrLocalityToStreetLocations < ActiveRecord::Migration
def change
rename_column :locations,:street_or_locality,:street
end
end
任何想法?
您需要发布您的迁移代码。 – lcguida
@MohitKumar请更新问题的代码 – Iceman
谢谢你的回应。我已经更新了问题中的代码。 –