1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00

Add Temporarily Turn Off Pending Migrations Error as a Rails TIL

This commit is contained in:
jbranchaud
2024-10-11 15:05:31 -05:00
parent dbb8c585c1
commit cc858382d8
2 changed files with 35 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1460 TILs and counting..._
_1461 TILs and counting..._
---
@@ -990,6 +990,7 @@ _1460 TILs and counting..._
- [Skip Validations When Creating A Record](rails/skip-validations-when-creating-a-record.md)
- [Specify New Attributes For #find_or_create_by](rails/specify-new-attributes-for-find-or-create-by.md)
- [Temporarily Disable strong_params](rails/temporarily-disable-strong-params.md)
- [Temporarily Turn Off Pending Migrations Error](rails/temporarily-turn-off-pending-migrations-error.md)
- [Test For A Subset Of Attributes On A Model](rails/test-for-a-subset-of-attributes-on-a-model.md)
- [Test If An Instance Variable Was Assigned](rails/test-if-an-instance-variable-was-assigned.md)
- [Test If deliver_later Is Called For A Mailer](rails/test-if-deliver-later-is-called-for-a-mailer.md)

View File

@@ -0,0 +1,33 @@
# Temporarily Turn Off Pending Migrations Error
Whenever I'm working on an end-to-end feature in a Rails app, soon or later I
am going to see the _Pending Migrations_ error page. I try to visit one of the
routes in the browser and the Rails app serves this error page instead of my
actual request response.
This is typically what I want. If there are migrations just sitting there that
haven't been run yet, that's probably an issue. Maybe I just pulled down the
latest changes from my teammates. The app isn't going to work properly without
whatever schema changes are prescribed in those pending migrations.
The thing to do is run those migrations.
In some special cases though, I know what I'm doing and I would like to operate
my app locally with specific migrations not yet applied.
To skip the error, I can change this `config/environments/development.rb`
setting from:
```ruby
config.active_record.migration_error = :page_load
```
to:
```ruby
config.active_record.migration_error = false
```
I just need to make sure to switch it back when I'm done.
[source](https://til.hashrocket.com/posts/ujcixh5rwi-rails-ignore-pending-migrations)