Skip to content

Commit

Permalink
Merge pull request ManageIQ#136 from Fryguy/fix_migration_column_cache
Browse files Browse the repository at this point in the history
Fix migration column caching.
  • Loading branch information
gtanzillo authored Nov 21, 2017
2 parents bdc5a90 + ff649d4 commit 2d091ff
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def change
add_index :container_quotas, :deleted_on

add_timestamps :container_quota_items, :null => true # temporarily for backfilling, then disallow nulls
ContainerQuotaItem.reset_column_information

reversible do |dir|
dir.up do
say_with_time("Backfilling container_quota_items timestamps from parent quotas") do
Expand All @@ -17,12 +19,13 @@ def change
now = Time.zone.now
ContainerQuotaItem.includes(:container_quota).find_each do |item|
# This also sets updated_at to migration time.
item.update_attributes(:created_at => item.container_quota.try(:created_on) || now)
item.update_attributes!(:created_at => item.container_quota.try(:created_on) || now)
end
end
end
# down: unnecessary, created_at/updated_at columns get deleted.
end

change_column_null :container_quota_items, :created_at, false
change_column_null :container_quota_items, :updated_at, false

Expand Down

0 comments on commit 2d091ff

Please sign in to comment.