FIX: Handle invalid JSON from downloaded_images custom fields (#16613)

custom_field data on some sites has duplicate values for a given url key in the JSON value. This is invalid, so we should drop the extra data.
This commit is contained in:
David Taylor 2022-05-03 18:51:25 +01:00 committed by GitHub
parent 175e6e6061
commit 1c9d8b4999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,7 @@ class CreatePostHotlinkedMedia < ActiveRecord::Migration[6.1]
JOIN json_each_text(pcf.value::json) obj ON true
JOIN uploads ON obj.value::bigint = uploads.id
WHERE name='downloaded_images'
ON CONFLICT (post_id, md5(url::text)) DO NOTHING
SQL
execute <<~SQL