1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Document the fact you can add_index on new columns

This commit is contained in:
Sammy Larbi 2013-04-17 16:16:47 -05:00
parent 14254d82a9
commit 1badf20497

View file

@ -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