Skip to content

Commit

Permalink
Reset model schema cache before each run
Browse files Browse the repository at this point in the history
  • Loading branch information
wildmaples committed Apr 25, 2024
1 parent 55fdca8 commit a83a107
Showing 1 changed file with 4 additions and 0 deletions.
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 a83a107

Please sign in to comment.