]> git.openstreetmap.org Git - rails.git/commitdiff
Backfill the creation_address column from creation_ip
authorTom Hughes <tom@compton.nu>
Thu, 12 Sep 2024 18:25:29 +0000 (19:25 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 13 Sep 2024 10:04:34 +0000 (11:04 +0100)
db/migrate/20240912181413_backfill_user_creation_address.rb [new file with mode: 0644]
db/structure.sql

diff --git a/db/migrate/20240912181413_backfill_user_creation_address.rb b/db/migrate/20240912181413_backfill_user_creation_address.rb
new file mode 100644 (file)
index 0000000..3cc14f2
--- /dev/null
@@ -0,0 +1,14 @@
+class BackfillUserCreationAddress < ActiveRecord::Migration[7.1]
+  class User < ApplicationRecord
+  end
+
+  def up
+    User
+      .where(:creation_address => nil)
+      .where.not(:creation_ip => nil)
+      .in_batches(:of => 1000)
+      .update_all("creation_address = creation_ip::inet")
+  end
+
+  def down; end
+end
index 9318185c6a22980ea96fe6689addd10c7f492f2a..60164558c9c3f47b6cab418a3a76af8cdcb4097f 100644 (file)
@@ -3357,6 +3357,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('23'),
 ('22'),
 ('21'),
+('20240912181413'),
 ('20240910175616'),
 ('20240822121603'),
 ('20240813070506'),