Update CreateComments migration to reflect the output from Rails 4.
This commit is contained in:
parent
757e985c6f
commit
092b952d47
@ -1148,19 +1148,17 @@ class CreateComments < ActiveRecord::Migration
|
||||
create_table :comments do |t|
|
||||
t.string :commenter
|
||||
t.text :body
|
||||
t.references :post
|
||||
t.references :post, index: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :comments, :post_id
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
The `t.references` line sets up a foreign key column for the association between
|
||||
the two models. And the `add_index` line sets up an index for this association
|
||||
column. Go ahead and run the migration:
|
||||
the two models. An index for this association is also created on this column.
|
||||
Go ahead and run the migration:
|
||||
|
||||
```bash
|
||||
$ rake db:migrate
|
||||
@ -1172,10 +1170,8 @@ run against the current database, so in this case you will just see:
|
||||
```bash
|
||||
== CreateComments: migrating =================================================
|
||||
-- create_table(:comments)
|
||||
-> 0.0008s
|
||||
-- add_index(:comments, :post_id)
|
||||
-> 0.0003s
|
||||
== CreateComments: migrated (0.0012s) ========================================
|
||||
-> 0.0115s
|
||||
== CreateComments: migrated (0.0119s) ========================================
|
||||
```
|
||||
|
||||
### Associating Models
|
||||
|
Loading…
Reference in New Issue
Block a user