data-migrate
data-migrate copied to clipboard
Delegate to anonymous subclass of AR::SchemaMigration
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.