Skip to content

Commit

Permalink
make db:migrate:redo rake task accept an optional VERSION to target t…
Browse files Browse the repository at this point in the history
…hat specific migration to redo

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information
phallstrom authored and NZKoz committed Sep 17, 2008
1 parent 4db7e8d commit c47525a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions railties/lib/tasks/databases.rake
Expand Up @@ -113,8 +113,16 @@ namespace :db do
end end


namespace :migrate do 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' 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 => [ 'db:rollback', 'db:migrate' ] 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' desc 'Resets your database using your migrations for the current environment'
task :reset => ["db:drop", "db:create", "db:migrate"] task :reset => ["db:drop", "db:create", "db:migrate"]
Expand Down

1 comment on commit c47525a

@ryenski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Please sign in to comment.