data-migrate icon indicating copy to clipboard operation
data-migrate copied to clipboard

Delegate to anonymous subclass of AR::SchemaMigration

Open defsprite opened this issue 2 years ago • 0 comments

I've found that adding the data_migrate gem will cause a database connection to be forced when running rails assets:precompile and was able to pin down the problem to the subclassing of ActiveRecord::SchemaMigration to create DataMigrate::DataSchemaMigration

Of course, there are workarounds like adding a nulldb adapter to make assets:precompile work in this situation, but I feel like a dependency should not force us to do this if at all possible.

Using composition in favour of inheritance and delegating to the instance does seem to fix the problem here, though there might be other ways to achieve this (e.g. deferred requiring of data_migrate/data_schema_migration)

This example app showcases the issue.

defsprite avatar Sep 05 '22 14:09 defsprite