Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1083577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:27:11+00:00 2026-05-16T22:27:11+00:00

I am using ruby on rails 2.3.9. The rake db:migrate passed successfully. However when

  • 0

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:27:12+00:00Added an answer on May 16, 2026 at 10:27 pm

    First, you should omit the parentheses after FOREIGN KEY. Second, you must tell mysql the name of the fk constraint you want to drop, not the name of the column affected by that constraint. If you run SHOW CREATE TABLE venues, you can find out the name of the constraint – probably something like venues_ibfk_1 or similar. Use this name for the ALTER TABLE statement, e.g. ALTER TABLE venues DROP FOREIGN KEY venues_ibfk_1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Helo, I am trying to run rake db:migrate for my rails 3 application using
Just a forewarning: I'm a rails noob. When I run: rake db:migrate I get
while attempting to run rake, I run into the following error: heroku rake db:migrate
Using Ruby on Rails. I'm trying to sort a query by number (saved as
using Ruby on Rails 2.3.2, since I already created Scaffold for Story, so instead
I am using Ruby on Rails, but I think this question could be applied
I'm using ruby on rails + jquery ajax My function is for user check
I am using Ruby on Rails 3.2.2 and MySQL. From the logger I know
I am using Ruby on Rails to develop a webapp. I want it so
I am using Ruby on Rails 3.2.2 and I would like to know if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.