mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:03:22 +08:00
FIX: Skip invalid custom_field json in hotlinked_media migration (#16630)
Truly testing for JSON validity would require defining a new postgres function. Checking just the first character should take care of all the cases of invalid historic data that we've seen.
This commit is contained in:
parent
62ed7d4968
commit
db9ae32e41
|
@ -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'
|
||||
AND pcf.value LIKE '{%' -- JSON Object
|
||||
ON CONFLICT (post_id, md5(url::text)) DO NOTHING
|
||||
SQL
|
||||
|
||||
|
@ -61,6 +62,7 @@ class CreatePostHotlinkedMedia < ActiveRecord::Migration[6.1]
|
|||
FROM post_custom_fields pcf
|
||||
JOIN json_array_elements_text(pcf.value::json) url ON true
|
||||
WHERE name='broken_images'
|
||||
AND pcf.value LIKE '[%' -- JSON Array
|
||||
ON CONFLICT (post_id, md5(url::text)) DO NOTHING
|
||||
SQL
|
||||
|
||||
|
@ -76,6 +78,7 @@ class CreatePostHotlinkedMedia < ActiveRecord::Migration[6.1]
|
|||
FROM post_custom_fields pcf
|
||||
JOIN json_array_elements_text(pcf.value::json) url ON true
|
||||
WHERE name='large_images'
|
||||
AND pcf.value LIKE '[%' -- JSON Array
|
||||
ON CONFLICT (post_id, md5(url::text)) DO NOTHING
|
||||
SQL
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user