Skip to content

Instantly share code, notes, and snippets.

@lancecarlson
Created March 3, 2009 23:19
Show Gist options
  • Save lancecarlson/73609 to your computer and use it in GitHub Desktop.
Save lancecarlson/73609 to your computer and use it in GitHub Desktop.
namespace :db do
desc "Perform automigration"
task :automigrate => :environment do
::DataMapper::AutoMigrator.auto_migrate
end
desc "Perform non destructive automigration"
task :autoupgrade => :environment do
::DataMapper::AutoMigrator.auto_upgrade
end
namespace :migrate do
task :load => :environment do
gem 'dm-migrations'
FileList["db/migrations/*.rb"].each do |migration|
load migration
end
end
desc "Migrate up using migrations"
task :up, :version, :needs => :load do |t, args|
version = args[:version]
migrate_up!(version)
end
desc "Migrate down using migrations"
task :down, :version, :needs => :load do |t, args|
version = args[:version]
migrate_down!(version)
end
end
desc "Migrate the database to the latest version"
task :migrate => 'db:migrate:up'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment