7600aef48b
As a side benefit, fix an (non-user-visible) bug in display_s5(). Also fixed a bug where removing orphaned pages did not expire cached summary pages.
23 lines
1.5 KiB
Plaintext
23 lines
1.5 KiB
Plaintext
Migrations
|
|
==========
|
|
|
|
Migrations are a convenient way for you to alter your database in a structured and organised manner. You could edit fragments of SQL by hand but you would then be responsible for telling other developers that they need to go and run it. You'd also have to keep track of which changes need to be run against the production machines next time you deploy. Active Record tracks which migrations have already been run so all you have to do is update your source and run `rake db:migrate`. Active Record will work out which migrations should be run.
|
|
|
|
Migrations also allow you to describe these transformations using Ruby. The great thing about this is that (like most of Active Record's functionality) it is database independent: you don't need to worry about the precise syntax of CREATE TABLE any more that you worry about variations on SELECT * (you can drop down to raw SQL for database specific features). For example you could use SQLite3 in development, but MySQL in production.
|
|
|
|
You'll learn all about migrations including:
|
|
|
|
* The generators you can use to create them
|
|
* The methods Active Record provides to manipulate your database
|
|
* The Rake tasks that manipulate them
|
|
* How they relate to `schema.rb`
|
|
|
|
include::anatomy_of_a_migration.txt[]
|
|
include::creating_a_migration.txt[]
|
|
include::writing_a_migration.txt[]
|
|
include::rakeing_around.txt[]
|
|
include::using_models_in_migrations.txt[]
|
|
include::scheming.txt[]
|
|
include::foreign_keys.txt[]
|
|
include::changelog.txt[]
|