Skip to content

Commit

Permalink
Merge pull request #307 from ilyakatz/fix-model-schema-cache-issue
Browse files Browse the repository at this point in the history
Reset model schema cache before each run
  • Loading branch information
wildmaples authored Apr 25, 2024
2 parents 55fdca8 + a060bea commit 823d33a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 4 additions & 0 deletions lib/data_migrate/data_migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 823d33a

Please sign in to comment.