aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSammy Larbi <sam@codeodor.com>2013-04-17 16:16:47 -0500
committerSammy Larbi <sam@codeodor.com>2013-04-17 16:16:47 -0500
commit1badf20497828cf20f86455fb958832cc5104c08 (patch)
tree241b2a67aa0a34c0b563613faef1247b42e96dfc
parent14254d82a90b8aa4bd81f7eeebe33885bf83c378 (diff)
downloadrails-1badf20497828cf20f86455fb958832cc5104c08.tar.gz
rails-1badf20497828cf20f86455fb958832cc5104c08.tar.bz2
rails-1badf20497828cf20f86455fb958832cc5104c08.zip
Document the fact you can add_index on new columns
-rw-r--r--guides/source/migrations.md20
1 files changed, 19 insertions, 1 deletions
diff --git a/guides/source/migrations.md b/guides/source/migrations.md
index 086cf434d9..9c92efd521 100644
--- a/guides/source/migrations.md
+++ b/guides/source/migrations.md
@@ -150,7 +150,25 @@ class AddPartNumberToProducts < ActiveRecord::Migration
end
```
-Similarly,
+If you'd like to add an index on the new column, you can do that as well:
+
+```bash
+$ rails generate migration AddPartNumberToProducts part_number:string:index
+```
+
+will generate
+
+```ruby
+class AddPartNumberToProducts < ActiveRecord::Migration
+ def change
+ add_column :products, :part_number, :string
+ add_index :products, :part_number
+ end
+end
+```
+
+
+Similarly, you can generate a migration to remove a column from the command line:
```bash
$ rails generate migration RemovePartNumberFromProducts part_number:string