diff options
author | Douglas Teoh <douglas@dteoh.com> | 2013-05-04 18:00:26 +1000 |
---|---|---|
committer | Douglas Teoh <douglas@dteoh.com> | 2013-05-04 18:00:26 +1000 |
commit | 092b952d472c450e1207dba2b63af0f765f78b8f (patch) | |
tree | 336bd684e7ca8854f7a98c22d80e4434a86afdc3 /guides | |
parent | 757e985c6f488707264aa37fe0bcfdaa7a8a06ca (diff) | |
download | rails-092b952d472c450e1207dba2b63af0f765f78b8f.tar.gz rails-092b952d472c450e1207dba2b63af0f765f78b8f.tar.bz2 rails-092b952d472c450e1207dba2b63af0f765f78b8f.zip |
Update CreateComments migration to reflect the output from Rails 4.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/getting_started.md | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 43bcbc9f42..599e47949d 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -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 |