<p></p>
<p><b>@gravitystorm</b> requested changes on this pull request.</p>

<p dir="auto">This is just an intermediate review, I've skimmed the rest but I haven't gone into detail yet.</p><hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481#discussion_r1472972526">lib/tasks/migrate_notes.rake</a>:</p>
<pre style='color:#555'>> +  desc "Backfills notes-columns `body`, `author_ip` and `author_id`"
+  task :migrate_notes => :environment do
+    scope = Note.where(:body => nil, :author => nil, :author_ip => nil)
+    total_count = scope.count
+    remaining_count = total_count
+    puts "A total of #{total_count} Note-records have to be migrated."
+
+    # NB: default batch size is 1000
+    scope.find_in_batches do |batch|
+      puts "Processing batch of #{batch.size} records."
+      batch.each do |record|
+        opened_comment = record.comments.unscope(:where => :visible).find_by(:event => "opened")
+        (putc "x" && next) unless opened_comment
+
+        attributes = opened_comment.attributes.slice(*%w[body author_id author_ip]).compact_blank
+        record.update_columns(attributes) # rubocop:disable Rails/SkipsModelValidations
</pre>
<p dir="auto">I think this needs to remote the comment too, right? Otherwise there will be a body, and then the first comment will duplicate the body.</p>
<p dir="auto">I also think this needs to have tests, and so I would move all the logic into the app (e.g. Note.migrate_bodies, or a standalone class in lib, or somesuch) to make it easier to test. The rake task can then just be a one-liner to call that method and therefore doesn't need tests itself.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481#pullrequestreview-1853988999">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLJAGLSK2IGLSLZOQ5DYRJNSRAVCNFSM6AAAAABB4FLGOWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNJTHE4DQOJZHE">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLPIJEXQ3E4YZ2ZBO3TYRJNSRA5CNFSM6AAAAABB4FLGOWWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTTOQGQIO.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/4481/review/1853988999</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/4481#pullrequestreview-1853988999",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4481#pullrequestreview-1853988999",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>