FIX: Skip invalid values in site setting upload references migration (#17138)

This commit is contained in:
David Taylor 2022-06-19 19:02:55 +01:00 committed by GitHub
parent 7ac485fb9f
commit 410ab5d587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -4,9 +4,13 @@ class CopySiteSettingsUploadsToUploadReferences < ActiveRecord::Migration[6.1]
def up
execute <<~SQL
WITH site_settings_uploads AS (
SELECT id, unnest(string_to_array(value, '|'))::integer upload_id
FROM site_settings
WHERE data_type = 17
SELECT id, raw_upload_id::integer AS upload_id
FROM (
SELECT id, unnest(string_to_array(value, '|')) AS raw_upload_id
FROM site_settings
WHERE data_type = 17
) raw
WHERE raw_upload_id ~ '^\d+$'
UNION
SELECT id, value::integer
FROM site_settings