Permalink
Browse files

Stylistic cleanups

  • Loading branch information...
fcheung committed Sep 7, 2008
1 parent 67f50bd commit e4167b8d0bfdb74c909f47c79defa9d57aa5b4a8
@@ -1,6 +1,6 @@
== Anatomy Of A Migration ==
-Before we dive into the details of a migration, here is a typical example:
+Before I dive into the details of a migration, here is a typical example:
[source, ruby]
------------------------
@@ -25,7 +25,7 @@ This migration adds a table called products with a string column called `name` a
=== Migrations are classes
A migration is a subclass of `ActiveRecord::Migration` that implements two class methods: +up+ (perform the required transformations) and +down+ (revert them).
-Methods are provided that perform common data definition tasks in a database independent way (we'll look at them in detail later):
+ActiveRecord provides methods that perform common data definition tasks in a database independent way (you'll read about them in detail later):
* `create_table`
* `change_table`
@@ -84,7 +84,7 @@ class RemovePartNumberFromProducts < ActiveRecord::Migration
end
-----------------------
-You aren't limited to one magically generated column, for example
+You are not limited to one magically generated column, for example
`ruby script/generate migration AddDetailsToProducts part_number:string price:decimal`
@@ -5,7 +5,7 @@ Migrations are a convenient way for you to alter your database in a structured a
Migrations also allow you to describe these transformation using ruby, in a database independent way (you can drop down to raw SQL for database specific features).
-Rails packages a number of rake tasks and generators for working with migrations and we'll talk about those too.
+Rails packages a number of rake tasks and generators for working with migrations and you'll learn about those too.
include::anatomy_of_a_migration.txt[]
include::creating_a_migration.txt[]
@@ -71,7 +71,7 @@ class CreateProducts < ActiveRecord::Migration
t.timestamps
end
end
- say "we created a table"
+ say "Created a table"
suppress_messages {add_index :products, :name}
say "and an index!", true
say_with_time 'Waiting for a while' do
@@ -89,7 +89,7 @@ end
generates the following output
----------------------
== 20080906170109 CreateProducts: migrating ===================================
--- we created a table
+-- Created a table
-> and an index!
-- Waiting for a while
-> 10.0001s
@@ -2,7 +2,7 @@
When creating or updating data in a migration it is often tempting to use one of your models. After all they exist to provide easy access to the underlying data. This can be done but some caution should be observed. Consider for example a migration that uses the Product model to update a row in the corresponding table. Alice later updates the Product model, adding a new column and a validation on it. Bob comes back from holiday, updates the source and runs outstanding migrations with `rake db:migrate`, including the one that used the Product model. When the migration runs the source is up to date and so the Product model has the validation added by Alice. The database however is still old and so does not have that column and an error ensues.
-Frequently one only wishes to update rows in the database without writing out the sql by hand: we're not using anything actually specific to the model. One pattern for this is to define a copy of the model inside the migration itself, for example:
+Frequently I just want to update rows in the database without writing out the sql by hand: I'm notusing anything specific to the model. One pattern for this is to define a copy of the model inside the migration itself, for example:
[source, ruby]
-------------------------

0 comments on commit e4167b8

Please sign in to comment.