Skip to content

Instantly share code, notes, and snippets.

@MirkoCindric
Created July 7, 2010 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MirkoCindric/466646 to your computer and use it in GitHub Desktop.
Save MirkoCindric/466646 to your computer and use it in GitHub Desktop.
#Simple task that updates development and test db all at once.
namespace :db do
namespace :migrate do
desc "Migrates development and test databases"
task :all do
puts "Migrating development database"
Rake::Task["db:migrate"].invoke
puts "Migrating test database"
Rake::Task["db:test:clone"].invoke
end
desc "Rollback the database schema to the previous version"
task :rollback => :environment do
previous_version = ActiveRecord::Migrator.current_version.to_i - 1
ActiveRecord::Migrator.migrate("db/migrate/", previous_version)
puts "Schema rolled back to previous verison (#{previous_version})."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment