Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset model schema cache before each run #307

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading