diff --git a/Changelog.md b/Changelog.md index 9a4c63a..6ff62e5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 9.4.0 +- Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307 + ## 9.3.0 - Improve with_data Rake task for multiple database https://github.com/ilyakatz/data-migrate/pull/296 diff --git a/lib/data_migrate/data_migrator.rb b/lib/data_migrate/data_migrator.rb index 300cde7..26a08dc 100644 --- a/lib/data_migrate/data_migrator.rb +++ b/lib/data_migrate/data_migrator.rb @@ -54,6 +54,10 @@ def migrations(_migrations_paths) #TODO: this was added to be backward compatible, need to re-evaluate def run(direction, migration_paths, version) + # Ensure all Active Record model cache is reset for each data migration + # As recommended in: https://github.com/rails/rails/blob/da21c2e9812e5eb0698fba4a9aa38632fc004432/activerecord/lib/active_record/migration.rb#L467-L470 + ActiveRecord::Base.descendants.each(&:reset_column_information) + DataMigrate::MigrationContext.new(migration_paths).run(direction, version) end