我試圖在下面提到的服務器上運行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
謝謝你的迴應。我已經更新了問題中的代碼。 –