Reputation: 2491
I have tried to run rake db:migrate on below-mentioned servers.
1st Server:
OS: Ubuntu 14.04 Trusty
Mysql Version: 5.6.33
Rake Version: 12.0.0
2nd Server:
OS: Ubuntu 16.04 Xeniel
Mysql Version: 5.6.2
Rake Version: 10.4.2
I have run the migration on the first server it was completed successfully but when I am trying to run the rake DB migrate with the following command than getting the error.
RAILS_ENV="deve" bundle exec rake db:migrate
Error Code:
== 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'
Please find migration code below.
class RenameColumnStreetOrLocalityToStreetLocations < ActiveRecord::Migration
def change
rename_column :locations,:street_or_locality,:street
end
end
Any idea?
Upvotes: 1
Views: 269
Reputation: 2491
Just an update.
I have set up another server with ubuntu 14.04 trusty and same rake version. The database is still on AWS Aurora RDS with Engine version 5.6.2 and the migration has been completed now.
I am not sure if This was the actual problem but the issue has been resolved now.
Thank you.
Upvotes: 1
Reputation: 558
you'll need to remove => add indexes first since the index is based on the column name:
remove_index :locations, :street_or_locality
rename_column :locations, :street_or_locality, :street
add_index :locations, :street
Upvotes: 2