I have a legacy project which needs to be locked to ActiveRecord 5.2. It does not run Rails.
I have database migrations at a custom path in the project tree. I am trying to run the migrations but am hitting an error. This is what the code I am using to run the migrations looks like:
def self.migrations_path
File.expand_path('../schema', __FILE__)
end
ActiveRecord::MigrationContext.new(migrations_path).migrate(5.2)
but I receive the following error:
Failure/Error: ActiveRecord::MigrationContext.new(migrations_path).migrate(5.2)
ArgumentError:
wrong number of arguments (given 5, expected 1..4)
What is the correct way to run migrations without Rails on ActiveRecord 5.2 (version is actually 5.2.8.1)? Thanks for any help.
Edited to include full stack trace:
An error occurred while loading ./spec/spec_helper.rb. Failure/Error: ActiveRecord::MigrationContext.new(migrations_path).migrate(5.2)
ArgumentError:
wrong number of arguments (given 5, expected 1..4)
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:263:in `initialize'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/connection_adapters/sqlite3/schema_statements.rb:60:in `new'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/connection_adapters/sqlite3/schema_statements.rb:60:in `create_table_definition'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:291:in `create_table'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/schema_migration.rb:29:in `create_table'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/migration.rb:1187:in `initialize'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/migration.rb:1036:in `new'
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/migration.rb:1036:in `up'
# /usr/share/rvm/gems/rsongkickuby-3.0.1/gems/activerecord-5.2.8.1/lib/active_record/migration.rb:1017:in `migrate'
# ./lib/mycompany/oauth2/schema.rb:7:in `migrate'
# ./spec/spec_helper.rb:32:in `<top (required)>'
I tried upgrading to ActiveRecord 6.0 and I now get the following error:
Failure/Error: ActiveRecord::MigrationContext.new(migrations_path).migrate(6.0)
ArgumentError:
wrong number of arguments (given 1, expected 2)
# /usr/share/rvm/gems/ruby-3.0.1/gems/activerecord-6.0.0/lib/active_record/migration.rb:1028:in `initialize'
# ./lib/mycompany/oauth2/schema.rb:7:in `new'
# ./lib/mycompany/oauth2/schema.rb:7:in `migrate'
# ./spec/spec_helper.rb:32:in `<top (required)>'