Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
The database schema is behind the migration files in the app.
Seen on:
Ruby
Meaning
After pulling code with new migrations, deploying, or switching branches, Rails detects unapplied migrations and stops in development/test.
Common causes
- New migrations not yet run
- Test database not prepared
- Branch switch with different migrations
- Deploy script missing db:migrate
⚡ Quick fix
- Run bin/rails db:migrate
- For tests: bin/rails db:test:prepare
- Add db:migrate to deployment
Detailed fix by platform
Shell
- ruby
bin/rails db:migrate bin/rails db:migrate:status RAILS_ENV=test bin/rails db:prepare
How to diagnose
- Status — db:migrate:status
- Env — Which environment?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026