aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-03-25 13:53:23 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2015-03-25 13:53:23 +0100
commit348377da4d623a81b570b2bf46e6ef9e5ee4e12f (patch)
tree7d1f422ade0262b8df73756c45cb01bd4fab4ca2 /guides
parent30a5cd9c8b728af150e79bb06697de6f1adf2360 (diff)
parent4b87780abc2cc1ae0169f5ca14d7632bd6dc30ec (diff)
downloadrails-348377da4d623a81b570b2bf46e6ef9e5ee4e12f.tar.gz
rails-348377da4d623a81b570b2bf46e6ef9e5ee4e12f.tar.bz2
rails-348377da4d623a81b570b2bf46e6ef9e5ee4e12f.zip
Merge pull request #19496 from andreynering/docs-migrations-change
Documenting remove_column as a reversible migration method
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_migrations.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md
index a2b7b7a818..de8bbc4174 100644
--- a/guides/source/active_record_migrations.md
+++ b/guides/source/active_record_migrations.md
@@ -539,6 +539,14 @@ definitions:
`change_table` is also reversible, as long as the block does not call `change`,
`change_default` or `remove`.
+`remove_column` is reversible if you supply the column type as the third
+argument. Provide the original column options too, otherwise Rails can't
+recreate the column exactly when rolling back:
+
+```ruby
+remove_column :posts, :slug, :string, null: false, default: '', index: true
+```
+
If you're going to need to use any other methods, you should use `reversible`
or write the `up` and `down` methods instead of using the `change` method.