diff options
author | Philip Hallstrom <philip@pjkh.com> | 2008-09-16 10:38:13 -0700 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-09-17 11:14:21 +0200 |
commit | c47525a58397851895b25f7c1bba06b30b0f6b5d (patch) | |
tree | 8ffbb9993a267df3f7931dc9c68d764bbd694146 /railties | |
parent | 4db7e8de1160de6c813a33266fa415849e25fba6 (diff) | |
download | rails-c47525a58397851895b25f7c1bba06b30b0f6b5d.tar.gz rails-c47525a58397851895b25f7c1bba06b30b0f6b5d.tar.bz2 rails-c47525a58397851895b25f7c1bba06b30b0f6b5d.zip |
make db:migrate:redo rake task accept an optional VERSION to target that specific migration to redo
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'railties')
-rw-r--r-- | 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 cc079b1d93..1431aa6944 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"] |