mirror of
https://github.com/jbranchaud/til
synced 2026-01-20 15:38:02 +00:00
Compare commits
1 Commits
db05ecff7c
...
251853eca9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
251853eca9 |
@@ -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).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1458 TILs and counting..._
|
_1457 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -965,7 +965,6 @@ _1458 TILs and counting..._
|
|||||||
- [Rescue From With A Separate Method](rails/rescue-from-with-a-separate-method.md)
|
- [Rescue From With A Separate Method](rails/rescue-from-with-a-separate-method.md)
|
||||||
- [Respond With JSON Regardless of Content Type](rails/respond-with-json-regardless-of-content-type.md)
|
- [Respond With JSON Regardless of Content Type](rails/respond-with-json-regardless-of-content-type.md)
|
||||||
- [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md)
|
- [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md)
|
||||||
- [Rollback A Couple Migrations](rails/rollback-a-couple-migrations.md)
|
|
||||||
- [Rollback A Specific Migration Out Of Order](rails/rollback-a-specific-migration-out-of-order.md)
|
- [Rollback A Specific Migration Out Of Order](rails/rollback-a-specific-migration-out-of-order.md)
|
||||||
- [Rounding Numbers With Precision](rails/rounding-numbers-with-precision.md)
|
- [Rounding Numbers With Precision](rails/rounding-numbers-with-precision.md)
|
||||||
- [Run A Rake Task Programmatically](rails/run-a-rake-task-programmatically.md)
|
- [Run A Rake Task Programmatically](rails/run-a-rake-task-programmatically.md)
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
# Rollback A Couple Migrations
|
|
||||||
|
|
||||||
Let's say we need to rollback a couple Rails migrations that have been applied
|
|
||||||
to our local environment. We run `rails db:migrate:status` and see that there
|
|
||||||
are _2_ migrations that we want to _undo_.
|
|
||||||
|
|
||||||
We can accomplish this by using the `STEP` env var with the rollback command.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ rails db:rollback STEP=2
|
|
||||||
```
|
|
||||||
|
|
||||||
Just set `STEP` to the number of migrations that we need to rollback. If we
|
|
||||||
then rerun `rails db:migrate:status` we'll now see those latest two migrations
|
|
||||||
are `down`.
|
|
||||||
|
|
||||||
Note: by default Rails doesn't like to operate with pending migrations. If we
|
|
||||||
want to temporarily disable the pending migration check, we can alter the
|
|
||||||
migration error config in `config/development.rb`.
|
|
||||||
|
|
||||||
```diff
|
|
||||||
# Raise an error on page load if there are pending migrations.
|
|
||||||
- # config.active_record.migration_error = :page_load
|
|
||||||
+ config.active_record.migration_error = false
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user