This content originally appeared on DEV Community and was authored by Alexandre Calaça
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.
Done
This content originally appeared on DEV Community and was authored by Alexandre Calaça
Alexandre Calaça | Sciencx (2024-09-22T02:30:45+00:00) How to temporarily skip the pending migration check in Rails. Retrieved from https://www.scien.cx/2024/09/22/how-to-temporarily-skip-the-pending-migration-check-in-rails/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.