How to temporarily skip the pending migration check in Rails

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…


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

Image Check the error

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

Image Skip Migration pending

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

Image Uncomment Migration check

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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » How to temporarily skip the pending migration check in Rails." Alexandre Calaça | Sciencx - Sunday September 22, 2024, https://www.scien.cx/2024/09/22/how-to-temporarily-skip-the-pending-migration-check-in-rails/
HARVARD
Alexandre Calaça | Sciencx Sunday September 22, 2024 » How to temporarily skip the pending migration check in Rails., viewed ,<https://www.scien.cx/2024/09/22/how-to-temporarily-skip-the-pending-migration-check-in-rails/>
VANCOUVER
Alexandre Calaça | Sciencx - » How to temporarily skip the pending migration check in Rails. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/22/how-to-temporarily-skip-the-pending-migration-check-in-rails/
CHICAGO
" » How to temporarily skip the pending migration check in Rails." Alexandre Calaça | Sciencx - Accessed . https://www.scien.cx/2024/09/22/how-to-temporarily-skip-the-pending-migration-check-in-rails/
IEEE
" » How to temporarily skip the pending migration check in Rails." Alexandre Calaça | Sciencx [Online]. Available: https://www.scien.cx/2024/09/22/how-to-temporarily-skip-the-pending-migration-check-in-rails/. [Accessed: ]
rf:citation
» How to temporarily skip the pending migration check in Rails | Alexandre Calaça | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.