ActiveRecord::IrreversibleMigration Ruby / Rails Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

Rails: ActiveRecord::IrreversibleMigration — This migration uses remove_column without a type; db:rollback can't reverse it

rails db:rollback can't undo the migration because it contains an operation Rails can't invert.

Exact message you may see StandardError: An error has occurred, this and all later migrations canceled: ActiveRecord::IrreversibleMigrationThis migration uses remove_column which is not automatically reversibleActiveRecord::IrreversibleMigration: This migration uses execute, which is not automatically reversible
Seen on: Ruby

Meaning

Define explicit up and down, or give reversible hints (remove_column :users, :age, :integer; change_table with types), or use reversible do |dir|. Data migrations and raw SQL need up/down. Don't edit applied migrations in shared branches — add a new one.

Common causes

  • remove_column without type
  • execute raw SQL in change
  • change_column without change_column_default info
  • Data transformation
  • Dropping tables without a definition

⚡ Quick fix

  1. Provide down or reversible do |dir| dir.up { ... } dir.down { ... } end
  2. Give column types to remove_column so it's reversible
  3. Raise IrreversibleMigration intentionally only if truly irreversible

Detailed fix by platform

Rails

  1. def change; remove_column :users, :age, :integer; end # reversible with type

How to diagnose

  1. Operation — Irreversible?
  2. Type — Provided?
  3. Plan — up/down?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1022 — MySQL ERROR 1022 (23000): Can't write; duplicate key in table (MySQL)10221051 — MySQL ERROR 1051 (42S02): Unknown table 'x' (MySQL)10511060 — MySQL ERROR 1060 (42S21): Duplicate column name 'x' (MySQL)10601061 — MySQL ERROR 1061 (42000): Duplicate key name 'x' (MySQL)10611091 — MySQL ERROR 1091 (42000): Can't DROP 'x'; check that column/key exists (MySQL)10911146 — MySQL ERROR 1146 (42S02): Table 'db.table' doesn't exist (MySQL)11462BP01 — ERROR: cannot drop table x because other objects depend on it (PostgreSQL)2BP0142701 — ERROR: column "x" of relation "y" already exists (PostgreSQL)42701ActiveRec…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.