lib/migration_tools/tasks.rb in migration_tools-1.0.1 vs lib/migration_tools/tasks.rb in migration_tools-1.1.0
- old
+ new
@@ -21,12 +21,20 @@
@group = nil
@pending_migrations = nil
ENV['GROUP'] = group
end
+ def migrations_paths
+ if ActiveRecord::Migrator.respond_to?(:migrations_paths)
+ ActiveRecord::Migrator.migrations_paths
+ else
+ 'db/migrate'
+ end
+ end
+
def migrator
- @migrator ||= ActiveRecord::Migrator.new(:up, 'db/migrate')
+ @migrator ||= ActiveRecord::Migrator.new(:up, migrations_paths)
end
def pending_migrations
return @pending_migrations if @pending_migrations
@pending_migrations = migrator.pending_migrations
@@ -62,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, 'db/migrate', migration.version)
+ ActiveRecord::Migrator.run(:up, migrations_paths, migration.version)
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