lib/migration_tools/tasks.rb in migration_tools-1.2.0 vs lib/migration_tools/tasks.rb in migration_tools-1.2.1

- old
+ new

@@ -22,21 +22,21 @@ @pending_migrations = nil ENV['GROUP'] = group end def migrations_paths - if ActiveRecord::Migrator.respond_to?(:migrations_paths) - ActiveRecord::Migrator.migrations_paths + ActiveRecord::Migrator.migrations_paths + end + + def migrator(target_version = nil) + if ActiveRecord::VERSION::MAJOR > 3 + ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations(migrations_paths), target_version) else - 'db/migrate' + ActiveRecord::Migrator.new(:up, migrations_paths, target_version) end end - def migrator - @migrator ||= ActiveRecord::Migrator.new(:up, migrations_paths) - end - def pending_migrations return @pending_migrations if @pending_migrations @pending_migrations = migrator.pending_migrations @pending_migrations = @pending_migrations.select { |proxy| group.empty? || proxy.migration_group == group } @@ -70,10 +70,10 @@ notify "Please specify a migration group" elsif pending_migrations.empty? notify "Your database schema is up to date" else pending_migrations.each do |migration| - ActiveRecord::Migrator.run(:up, migrations_paths, migration.version) + migrator(migration.version).run end Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql end