aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-19 11:34:42 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-19 11:34:42 -0800
commita4d9b1d329ef897f6b23216b01cb510db35a37b5 (patch)
tree0d10011219516f2866c6fff0f74d881496845759 /activerecord/lib/active_record/migration.rb
parentdb32b545dadae7808c210cd7ceef949a620490f0 (diff)
downloadrails-a4d9b1d329ef897f6b23216b01cb510db35a37b5.tar.gz
rails-a4d9b1d329ef897f6b23216b01cb510db35a37b5.tar.bz2
rails-a4d9b1d329ef897f6b23216b01cb510db35a37b5.zip
adding documentation for reversible migrations
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r--activerecord/lib/active_record/migration.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 99dd50ccb1..f6321f1499 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -283,6 +283,38 @@ module ActiveRecord
#
# In application.rb.
#
+ # == Reversible Migrations
+ #
+ # Starting with Rails 3.1, you will be able to define reversible migrations.
+ # Reversible migrations are migrations that know how to go +down+ for you.
+ # You simply supply the +up+ logic, and the Migration system will figure out
+ # how to execute the down commands for you.
+ #
+ # To define a reversible migration, define the +change+ method in your
+ # migration like this:
+ #
+ # class TenderloveMigration < ActiveRecord::Migration
+ # def change
+ # create_table(:horses) do
+ # t.column :content, :text
+ # t.column :remind_at, :datetime
+ # end
+ # end
+ # end
+ #
+ # This migration will create the horses table for you on the way up, and
+ # automatically figure out how to drop the table on the way down.
+ #
+ # Some commands like +remove_column+ cannot be reversed. If you care to
+ # define how to move up and down in these cases, you should define the +up+
+ # and +down+ methods as before.
+ #
+ # If a command cannot be reversed, an
+ # <tt>ActiveRecord::IrreversibleMigration</tt> exception will be raised when
+ # the migration is moving down.
+ #
+ # For a list of commands that are reversible, please see
+ # <tt>ActiveRecord::Migration::CommandRecorder</tt>.
class Migration
autoload :CommandRecorder, 'active_record/migration/command_recorder'