Rails 5.2 alternative to ActiveRecord::Migrator.up()

Viewed 238

In my rails app I have ActiveRecord::Migrator.up('db/views/') and ActiveRecord::Migrator.down('db/views/'). After updading to rails 5.2 it seems that this function has been removed. I attempted to use ActiveRecord::Migration.down('db/views/') but it seems that this function does not take any parameters.

What would be the modern alternative for ActiveRecord::Migrator.up(')?

1 Answers

A bit late, but I've achieved the same behaviour in an app using ActiveRecord::MigrationContext

migrations_path = 'db/views/'
if ActiveRecord.version.version >= '5.2'
  ActiveRecord::MigrationContext.new(migrations_path).up
else
  ActiveRecord::Migrator.up(migrations_path)
end
Related