In my rails 4.2 application, I used a task to perform the migration up as below:
ActiveRecord::Migrator.run(:up, ActiveRecord::Migrator.migrations_path, 20130306070257)
But, this is not working after I upgrade the application to rails 6. The error showing is:
NoMethodError: undefined method `migrations_path' for ActiveRecord::Migrator:Class
Did you mean? migrations_paths
migrations_paths=
Then, I tried the below function:
ActiveRecord::Migrator.run(:up,20130306070257).
Then, I got the below error:
ActiveRecord::Migrator.run(:up, NoMethodError: undefined method `run' for ActiveRecord::Migrator:Class
From application path, If I give : rake db:migrate:up VERSION=20130306070257 , it will work.
Please help me to correct the task. Thanks.
In rails 6 run is instance method.(https://www.rubydoc.info/gems/activerecord/ActiveRecord/Migrator) So you can use it like this:
Replace 'ClassName' with the name of your class name. For example, if your migration starts with class CreateUser < ActiveRecord::Migration[6.0, add 'CreateUser' instead 'ClassName'