From: Anton Khorev Date: Thu, 22 Aug 2024 12:45:59 +0000 (+0300) Subject: Backfill block deactivates_at X-Git-Tag: live~224^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3bba84ed3abbb9badfe8833e4aae7ceaeeb8586e?hp=-c Backfill block deactivates_at --- 3bba84ed3abbb9badfe8833e4aae7ceaeeb8586e diff --git a/db/migrate/20240822121603_backfill_deactivates_at_in_user_blocks.rb b/db/migrate/20240822121603_backfill_deactivates_at_in_user_blocks.rb new file mode 100644 index 000000000..38c010c44 --- /dev/null +++ b/db/migrate/20240822121603_backfill_deactivates_at_in_user_blocks.rb @@ -0,0 +1,11 @@ +class BackfillDeactivatesAtInUserBlocks < ActiveRecord::Migration[7.1] + class UserBlock < ApplicationRecord; end + + disable_ddl_transaction! + + def up + UserBlock.where(:needs_view => false, :deactivates_at => nil).in_batches do |relation| + relation.update_all("deactivates_at = GREATEST(ends_at, updated_at)") + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 18884b058..49cd4b9fb 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3579,6 +3579,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('23'), ('22'), ('21'), +('20240822121603'), ('20240813070506'), ('20240618193051'), ('20240605134916'),