lib/migration_tools/tasks.rb in migration_tools-0.1.1 vs lib/migration_tools/tasks.rb in migration_tools-0.1.2

- old
+ new

@@ -9,11 +9,11 @@ define_convenience_tasks end def group return @group if @group - + @group = ENV['GROUP'].to_s raise "Invalid group \"#{@group}\"" if !@group.empty? && !MIGRATION_GROUPS.member?(@group) @group end @@ -45,18 +45,18 @@ def define_migrate_group namespace :db do namespace :migrate do desc 'Runs pending migrations for a given group' - task :group do + task :group => :environment do if group.empty? notify "Please specify a migration group" elsif pending_migrations.empty? notify "Your database schema is up to date" else pending_migrations.each do |migration| - migration.migrate + migration.migrate(:up) end end end end end @@ -65,11 +65,12 @@ 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 + MigrationTools::MIGRATION_GROUPS.each do |migration_group| + desc "#{ns == :list ? 'Lists' : 'Executes' } the migrations for group #{migration_group}" + task migration_group => :environment do ENV['GROUP'] = migration_group.to_s Rake::Task["db:migrate:#{ns}"].invoke end end end