Introduction
In a typical Rails development workflow, database migrations play a critical role in evolving the schema as the application grows.
Rails, by default, checks for pending migrations when starting the server, and if any exist, it raises an ActiveRecord::PendingMigrationError
.
While this safeguard prevents inconsistencies, there are times when temporarily skipping this check can be helpful.
Reproduce the error
Launch the server
rails server
Open the page
localhost:3000
Check the error
ActiveRecord::PendingMigrationError
Migrations are pending. To resolve this issue, run:
bin/rails db:migrate RAILS_ENV=development
You have 1 pending migration:
Output
Solution
Skip Migration pending
The first solution is to use the SKIP_PENDING_MIGRATIONS_CHECK=true
command before you launch the server.
SKIP_PENDING_MIGRATIONS_CHECK=true rails server
OUtput
Uncomment Migration check
In the application.rb
file or in any of the environments file, such as the config/environments/development.rb
file.
Change this line
config.active_record.migration_error = :page_load
to
config.active_record.migration_error = false
OUtput
If you do not have the previous line, just add it.
Top comments (0)