diff options
author | Trevor Turk <trevorturk@yahoo.com> | 2008-11-15 12:53:36 -0600 |
---|---|---|
committer | Trevor Turk <trevorturk@yahoo.com> | 2008-11-15 12:53:36 -0600 |
commit | 22a5acaa99f56e5a9b8ab39c8e24765c0f2ccba4 (patch) | |
tree | 8298740ddf151d31b322f17aa51dd75633b9a138 /railties | |
parent | 1d910aac0a90fc881224f90b1a380ffa5435eb9d (diff) | |
download | rails-22a5acaa99f56e5a9b8ab39c8e24765c0f2ccba4.tar.gz rails-22a5acaa99f56e5a9b8ab39c8e24765c0f2ccba4.tar.bz2 rails-22a5acaa99f56e5a9b8ab39c8e24765c0f2ccba4.zip |
note that rake:db:migrate updates db/schema.rb by invoking db:schema:dump
Diffstat (limited to 'railties')
-rw-r--r-- | railties/doc/guides/source/migrations/index.txt | 2 | ||||
-rw-r--r-- | railties/doc/guides/source/migrations/rakeing_around.txt | 2 | ||||
-rw-r--r-- | railties/lib/tasks/databases.rake | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/railties/doc/guides/source/migrations/index.txt b/railties/doc/guides/source/migrations/index.txt index be183e8597..1670b73178 100644 --- a/railties/doc/guides/source/migrations/index.txt +++ b/railties/doc/guides/source/migrations/index.txt @@ -1,7 +1,7 @@ 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 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. It will also update your db/schema.rb file to match the structure of your database. 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. diff --git a/railties/doc/guides/source/migrations/rakeing_around.txt b/railties/doc/guides/source/migrations/rakeing_around.txt index 6d8c43d7a3..b01451d54d 100644 --- a/railties/doc/guides/source/migrations/rakeing_around.txt +++ b/railties/doc/guides/source/migrations/rakeing_around.txt @@ -2,6 +2,8 @@ Rails provides a set of rake tasks to work with migrations which boils down to running certain sets of migrations. The very first migration related rake task you use will probably be `db:migrate`. In its most basic form it just runs the `up` method for all the migrations that have not yet been run. If there are no such migrations it exits. +Note that running the `db:migrate` also invokes the `db:schema:dump` task, which will update your db/schema.rb file to match the structure of your database. + If you specify a target version, Active Record will run the required migrations (up or down) until it has reached the specified version. The version is the numerical prefix on the migration's filename. For example to migrate to version 20080906120000 run diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 5cb27f1f10..1aa09f2e57 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -105,7 +105,7 @@ namespace :db do end - desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false." + desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false." task :migrate => :environment do ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) |