lib/migration_tools/tasks.rb in migration_tools-0.1.0 vs lib/migration_tools/tasks.rb in migration_tools-0.1.1
- old
+ new
@@ -4,10 +4,11 @@
module MigrationTools
class Tasks < ::Rake::TaskLib
def initialize
define_migrate_list
define_migrate_group
+ define_convenience_tasks
end
def group
return @group if @group
@@ -52,9 +53,26 @@
elsif pending_migrations.empty?
notify "Your database schema is up to date"
else
pending_migrations.each do |migration|
migration.migrate
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def define_convenience_tasks
+ namespace :db do
+ namespace :migrate do
+ [ :list, :group ].each do |ns|
+ namespace ns do
+ [ :before, :during, :after, :change ].each do |migration_group|
+ task migration_group do
+ ENV['GROUP'] = migration_group.to_s
+ Rake::Task["db:migrate:#{ns}"].invoke
+ end
end
end
end
end
end