Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8039

Show
Ignore:
Timestamp:
10/26/07 21:11:07 (2 years ago)
Author:
david
Message:

Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r8020 r8039  
    11*SVN* 
     2 
     3* Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy] 
    24 
    35* Fix typo in test_helper. Closes #9925 [viktor tron] 
  • trunk/railties/lib/tasks/databases.rake

    r7718 r8039  
    8585    ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) 
    8686    Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby 
     87  end 
     88 
     89  desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n' 
     90  task :rollback => :environment do 
     91    step = ENV['STEP'] ? ENV['STEP'].to_i : 1 
     92    version = ActiveRecord::Migrator.current_version - step 
     93    ActiveRecord::Migrator.migrate('db/migrate/', version) 
    8794  end 
    8895