From 9ab0aee030fbee67f6481dc79040fd9e99282c4f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 12 Sep 2024 19:25:29 +0100 Subject: [PATCH] Backfill the creation_address column from creation_ip --- ...0240912181413_backfill_user_creation_address.rb | 14 ++++++++++++++ db/structure.sql | 1 + 2 files changed, 15 insertions(+) create mode 100644 db/migrate/20240912181413_backfill_user_creation_address.rb diff --git a/db/migrate/20240912181413_backfill_user_creation_address.rb b/db/migrate/20240912181413_backfill_user_creation_address.rb new file mode 100644 index 000000000..3cc14f238 --- /dev/null +++ b/db/migrate/20240912181413_backfill_user_creation_address.rb @@ -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 diff --git a/db/structure.sql b/db/structure.sql index 9318185c6..60164558c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3357,6 +3357,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('23'), ('22'), ('21'), +('20240912181413'), ('20240910175616'), ('20240822121603'), ('20240813070506'), -- 2.39.5