I am trying to update a gem called textacular to be compatible with latest rails version.
In the development Rake-tasks we need to run a few ActiveRecord migrations - without Rails.
Today it looks like:
namespace :migrate do
    desc 'Run the test database migrations'
    task :up => :'db:connect' do
      ActiveRecord::Migrator.up 'db/migrate'
    end
    desc 'Reverse the test database migrations'
    task :down => :'db:connect' do
      ActiveRecord::Migrator.down 'db/migrate'
    end
end
However when using ActiveRecord >= 5, it fails with:
NoMethodError: undefined method 'up' for ActiveRecord::Migrator:Class.
I have tried to look through the source code for ActiveRecord, tried a bunch of different methods but have not managed to run the migrations.
Does anyone have a hint of what to do?
Edit
Using ActiveRecord::Migration.up does nothing, probably just returns based on the method.
Using ActiveRecord::Migration.migrate(:up) gives output:
==  ActiveRecord::Migration: migrating ========================================
==  ActiveRecord::Migration: migrated (0.0000s) ===============================
All migrations are in the folder db/migrate.
One of the primary aspects of ActiveRecord is that there is very little to no configuration needed. It follow convention over configuration. ActiveRecord is commonly used with the Ruby-on-Rails framework but you can use it with Sinatra or without any web framework if desired.
To run a specific migration up or down, use db:migrate:up or db:migrate:down . The version number in the above commands is the numeric prefix in the migration's filename. For example, to migrate to the migration 20160515085959_add_name_to_users. rb , you would use 20160515085959 as the version number.
You must rollback the migration (for example with bin/rails db:rollback ), edit your migration, and then run bin/rails db:migrate to run the corrected version.
rails db:reset:primary Drops and recreates the primary database from its schema for the current environment and loads the seeds. rails db:reset:secondary Drops and recreates the secondary database from its schema for the current environment and loads the seeds.
You can also use this command:
ActiveRecord::MigrationContext.new(Rails.root.join('db', 'migrate'), ActiveRecord::SchemaMigration).migrate
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With