aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2015-03-24 09:06:28 -0300
committerAndrey Nering <andrey.nering@gmail.com>2015-03-25 09:16:08 -0300
commit4b87780abc2cc1ae0169f5ca14d7632bd6dc30ec (patch)
tree7d1f422ade0262b8df73756c45cb01bd4fab4ca2 /guides
parent30a5cd9c8b728af150e79bb06697de6f1adf2360 (diff)
downloadrails-4b87780abc2cc1ae0169f5ca14d7632bd6dc30ec.tar.gz
rails-4b87780abc2cc1ae0169f5ca14d7632bd6dc30ec.tar.bz2
rails-4b87780abc2cc1ae0169f5ca14d7632bd6dc30ec.zip
Documenting remove_column as a reversible migration method [ci skip]
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.