lib/migration_tools/tasks.rb in migration_tools-0.1.2 vs lib/migration_tools/tasks.rb in migration_tools-0.1.3
- old
+ new
@@ -15,13 +15,17 @@
@group = ENV['GROUP'].to_s
raise "Invalid group \"#{@group}\"" if !@group.empty? && !MIGRATION_GROUPS.member?(@group)
@group
end
+ def migrator
+ @migrator ||= ActiveRecord::Migrator.new(:up, 'db/migrate')
+ end
+
def pending_migrations
return @pending_migrations if @pending_migrations
- @pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
+ @pending_migrations = migrator.pending_migrations
@pending_migrations = @pending_migrations.select { |proxy| group.empty? || proxy.migration_group == group }
@pending_migrations
end
@@ -53,9 +57,10 @@
elsif pending_migrations.empty?
notify "Your database schema is up to date"
else
pending_migrations.each do |migration|
migration.migrate(:up)
+ migrator.send(:record_version_state_after_migrating, migration.version)
end
end
end
end
end