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 7754949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:26:34+00:00 2026-06-01T12:26:34+00:00

I generated a rails 3.2 migration with an empty down function, because the migration

  • 0

I generated a rails 3.2 migration with an empty down function, because the migration is irreversible (and I don’t want to throw an exception). I run the migration successfully, but it has no effect. When I rollback, and run db:migrate again, the effects does apply.

I solved this easily by filling the empty down function with a code which does nothing, but it’s still pretty ugly.

Does anyone knows why this happens? Is this a rails bug?

  • 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-06-01T12:26:35+00:00Added an answer on June 1, 2026 at 12:26 pm

    The exception is throwed to prevent destroying your database, if its irreversable, then that’s probably the right thing to do.
    Your #down could look like this:

      def down
        raise ActiveRecord::IrreversibleMigration, "Explain why its irreversable!"
      end
    

    That will save others a lot of headache as it clearly notifies about irreversable migration and explains the reason behind it 🙂

    EDIT: I cannot confirm this behaviour for Rails 3.2.3. I’ve created several different migrations without #down, and no exceptino was raised. Maybe it’s something in your code, which you didn’t show a bit.

    EDIT 2: Just to recap, when you’re using up/down method, its your responsibility to raise ActiveRecord::IrreversibleMigration. In other case, nothing will happen (#down defined in AR will just return nil). The behaviour is different when you use #change. In some cases the mentioned exception can be raised by #inverse defined here: https://github.com/rails/rails/blob/565bfb9cd49285ebaa170141b4996c22ba81de43/activerecord/lib/active_record/migration/command_recorder.rb#L39 which is expected behaviour.

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

Sidebar

Related Questions

I am working on a rails project using svn. I generated a migration file
Is there an easy way to see the actual SQL generated by a rails
I'm using ruby on rails 2.3.2 and also using the acts_as_taggable_on puglin. That generated
I'd like to run the rails generate script and create a model that belongs
Hi I want to delete all stuff related to rails generate scaffold at once.
I've added a column to a db in rails via a migration, and updated
I'm completely new to Rails, but I've done quite a bit of searching and
I removed several tables in my Rails database by running rails generate migration RemoveObjects
I am a Rails beginner and trying to understand how rails migration works. I
I'm new to rails trying to modify a model generated by scaffolding in rails

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.