Permalink
Browse files

Document the fact you can add_index on new columns

  • Loading branch information...
1 parent 14254d8 commit 1badf20497828cf20f86455fb958832cc5104c08 @codeodor codeodor committed Apr 17, 2013
Showing with 19 additions and 1 deletion.
  1. +19 −1 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

0 comments on commit 1badf20

Please sign in to comment.