]> git.openstreetmap.org Git - rails.git/commitdiff
Backfill block deactivates_at
authorAnton Khorev <tony29@yandex.ru>
Thu, 22 Aug 2024 12:45:59 +0000 (15:45 +0300)
committerTom Hughes <tom@compton.nu>
Fri, 23 Aug 2024 17:25:14 +0000 (18:25 +0100)
db/migrate/20240822121603_backfill_deactivates_at_in_user_blocks.rb [new file with mode: 0644]
db/structure.sql

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 (file)
index 0000000..38c010c
--- /dev/null
@@ -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
index 18884b058a95e51fb35feeb4dc28ff3c9b5940e9..49cd4b9fba9082cc6434b448fca00464156e1beb 100644 (file)
@@ -3579,6 +3579,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('23'),
 ('22'),
 ('21'),
 ('23'),
 ('22'),
 ('21'),
+('20240822121603'),
 ('20240813070506'),
 ('20240618193051'),
 ('20240605134916'),
 ('20240813070506'),
 ('20240618193051'),
 ('20240605134916'),