Patch #36770

Fix to use a correct exception class ActiveRecord::IrreversibleMigration in migrations

Added by Go MAEDA 4 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Code cleanup/refactoring
Target version:5.0.0

Description

When I tried to perform a reverse migration of db/migrate/20090503121510_drop_members_role_id.rb, I came across the following "uninitialized constant" error.

== 20090503121510 DropMembersRoleId: reverting ================================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

uninitialized constant DropMembersRoleId::IrreversibleMigration

    raise IrreversibleMigration
          ^^^^^^^^^^^^^^^^^^^^^
/path/to/redmine/db/migrate/20090503121510_drop_members_role_id.rb:7:in `down'

It is due to an incorrect exception class given to raise method. The exception class should be ActiveRecord::IrreversibleMigration instead of IrreversibleMigration. I am attaching a patch to fix it. You will get the following error after the fix.

== 20090503121510 DropMembersRoleId: reverting ================================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

ActiveRecord::IrreversibleMigration
/path/to/redmine/db/migrate/20090503121510_drop_members_role_id.rb:7:in `down'

fix_irreversible_migration_exception_class.patch Magnifier (2.59 KB) Go MAEDA, 2022-03-16 07:08

Associated revisions

Revision 21458
Added by Go MAEDA 4 months ago

Fix to use a correct exception class ActiveRecord::IrreversibleMigration in migrations (#36770).

History

#1 Updated by Go MAEDA 4 months ago

  • Subject changed from Fix exception class from IrreversibleMigration to ActiveRecord::IrreversibleMigration to Fix to use a correct exception class ActiveRecord::IrreversibleMigration in migrations
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version set to 5.0.0

Committed the fix.

Also available in: Atom PDF