diff --git a/db/migrate/20171026114327_add_deleted_on_to_container_quota_and_items.rb b/db/migrate/20171026114327_add_deleted_on_to_container_quota_and_items.rb index ad6282248..0203eb8d3 100644 --- a/db/migrate/20171026114327_add_deleted_on_to_container_quota_and_items.rb +++ b/db/migrate/20171026114327_add_deleted_on_to_container_quota_and_items.rb @@ -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 @@ -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