I am using ruby on rails 2.3.9. The rake db:migrate passed successfully. However when I run rake db:migrate:redo to test the down part I get error message. I am using mysql with Innodb.
class AddConstraints < ActiveRecord::Migration
def self.up
ActiveRecord::Base.connection.execute <<-EOS
ALTER TABLE venues
ADD CONSTRAINT FOREIGN KEY (city_id)
REFERENCES cities (id)
ON DELETE restrict
ON UPDATE cascade
EOS
end
def self.down
ActiveRecord::Base.connection.execute <<-EOS
ALTER TABLE venues DROP FOREIGN KEY (city_id)
EOS
end
end
The error message I am getting is
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 '(city_id)' at line 1:
ALTER TABLE venues DROP FOREIGN KEY (city_id)