aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-10-26 21:11:07 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-10-26 21:11:07 +0000
commit2a74d71e49604e21e03a002d38f0c68d0be81574 (patch)
tree48943d0abc56133b8171b5ba6787dce77394150f
parent49eafd8c3620bf8e46d21d447fc634a12c8280ab (diff)
downloadrails-2a74d71e49604e21e03a002d38f0c68d0be81574.tar.gz
rails-2a74d71e49604e21e03a002d38f0c68d0be81574.tar.bz2
rails-2a74d71e49604e21e03a002d38f0c68d0be81574.zip
Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8039 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/tasks/databases.rake7
2 files changed, 9 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 26b16de209..7aaad9a895 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy]
+
* Fix typo in test_helper. Closes #9925 [viktor tron]
* Request profiler. [Jeremy Kemper]
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']