Since the newest Rails version, ActiveRecord::MigrationContext#new
seems to take a new argument called schema_migration
. But I have no idea what to pass there and where to get it.
I cannot find any information on it. I googled for an hour, all examples for MigrationContext
I found referred to older rails versions. The class MigrationContext doesn't seem to be documented at all. From the source code I couldn't figure out what to pass either.
Some context: I am trying to test some of my more dangerous migrations. I found quite a few tutorials and it seemed easy and I went along an did it. But the code that prepares the state of the test db so I can apply the migration is currently not working. Sadly all the tutorials used older Rails versions and this fails due to the wrong number of arguments:
ActiveRecord::MigrationContext.new(migrations_paths)
I found out what I need to pass:
ActiveRecord::Base.connection.schema_migration
So the whole code would be:
migrations_paths = ActiveRecord::Migrator.migrations_paths
schema_migration = ActiveRecord::Base.connection.schema_migration
migration_context = ActiveRecord::MigrationContext.new(migrations_paths, schema_migration)
I googled and tried for an hour and didn't figure it out, but just after posting the question, I finally stumbled upon this github issue https://github.com/pat/combustion/issues/98 which had the same problem and a solution.