From f45379e387903d369ad8a1c7b2d1e0aee0ad68ba Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 1 Jan 2016 12:26:45 -0600 Subject: [PATCH] Add Migrating Up Down Up as a rails til. --- README.md | 1 + rails/migrating-up-down-up.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 rails/migrating-up-down-up.md diff --git a/README.md b/README.md index 0364c88..be59a84 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Creating Records of Has_One Associations](rails/creating-records-of-has-one-associations.md) - [Hash Slicing](rails/hash-slicing.md) - [Ignore Poltergeist JavaScript Errors](rails/ignore-poltergeist-javascript-errors.md) +- [Migrating Up Down Up](rails/migrating-up-down-up.md) - [Params Includes Submission Button Info](rails/params-includes-submission-button-info.md) - [Pretend Generations](rails/pretend-generations.md) - [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md) diff --git a/rails/migrating-up-down-up.md b/rails/migrating-up-down-up.md new file mode 100644 index 0000000..76a72e2 --- /dev/null +++ b/rails/migrating-up-down-up.md @@ -0,0 +1,16 @@ +# Migrating Up Down Up + +When writing Rails migrations, it is good to define, when possible, what +should happen when migrating *up* and what should happen when migrating +*down*. You'll then want to check that both the *up* and *down* work. This +can be accomplished using the following one-liner: + +```bash +$ rake db:migration && rake db:migration:redo +``` + +The `rake db:migration` does what we would expect applying our new migration +and showing us that our *up* works. The `rake db:migrate:redo` first +performs a rollback, showing us that our *down* works, and then migrates +back up again. We now know that our latest migration works going both +directions.