From 3a0f148ec4fa1c338900f21d62d45d9596568f06 Mon Sep 17 00:00:00 2001 From: Philip Hallstrom Date: Tue, 16 Sep 2008 10:38:13 -0700 Subject: [PATCH] make db:migrate:redo rake task accept an optional VERSION to target that specific migration to redo --- railties/lib/tasks/databases.rake | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index cc079b1..1431aa6 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -113,8 +113,16 @@ namespace :db do end namespace :migrate do - desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x' - task :redo => [ 'db:rollback', 'db:migrate' ] + desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.' + task :redo => :environment do + if ENV["VERSION"] + Rake::Task["db:migrate:down"].invoke + Rake::Task["db:migrate:up"].invoke + else + Rake::Task["db:rollback"].invoke + Rake::Task["db:migrate"].invoke + end + end desc 'Resets your database using your migrations for the current environment' task :reset => ["db:drop", "db:create", "db:migrate"] -- 1.5.6.2