Skip to content

Commit

Permalink
Document the fact you can add_index on new columns
Browse files Browse the repository at this point in the history
  • Loading branch information
codeodor committed Apr 17, 2013
1 parent 14254d8 commit 1badf20
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion guides/source/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1badf20

Please sign in to comment.