aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/tasks/databases.rake
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/tasks/databases.rake')
-rw-r--r--railties/lib/tasks/databases.rake7
1 files changed, 7 insertions, 0 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index fb477bce62..85cbb42fe3 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -86,6 +86,13 @@ namespace :db do
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
end
+ desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
+ task :rollback => :environment do
+ step = ENV['STEP'] ? ENV['STEP'].to_i : 1
+ version = ActiveRecord::Migrator.current_version - step
+ ActiveRecord::Migrator.migrate('db/migrate/', version)
+ end
+
desc 'Drops, creates and then migrates the database for the current environment. Target specific version with VERSION=x'
task :reset => ['db:drop', 'db:create', 'db:migrate']