DEV: use upload id to save in theme setting instead of URL. (#14341)

When we use URL instead it creates the problem while changing the CDN hostname.
This commit is contained in:
Vinoth Kannan
2021-09-16 07:58:53 +05:30
committed by GitHub
parent 91453dd3fc
commit a6de4a5ce9
7 changed files with 89 additions and 6 deletions

View File

@@ -0,0 +1,19 @@
# frozen_string_literal: true
class UpdateValueOnThemeSettingForUploadType < ActiveRecord::Migration[6.1]
def up
execute <<~SQL
UPDATE theme_settings
SET value = (SELECT id FROM uploads WHERE uploads.url = theme_settings.value)
WHERE data_type = 6
SQL
end
def down
execute <<~SQL
UPDATE theme_settings
SET value = (SELECT url FROM uploads WHERE uploads.id = theme_settings.value)
WHERE data_type = 6
SQL
end
end