mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06:00
FIX: Migrate old null override for upload site settings.
For some reason, setting a text site setting to empty in the past can
result in either an empty string or null as the value. This migration
is a follow up to 1981add261
.
This commit is contained in:
parent
37c613dde2
commit
cb1f909fa4
@ -0,0 +1,40 @@
|
||||
class MigrateNullOverrideForUploadSiteSettings < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
{
|
||||
'logo_url' => 'logo',
|
||||
'logo_small_url' => 'logo_small',
|
||||
'digest_logo_url' => 'digest_logo',
|
||||
'mobile_logo_url' => 'mobile_logo',
|
||||
'large_icon_url' => 'large_icon',
|
||||
'favicon_url' => 'favicon',
|
||||
'apple_touch_icon_url' => 'apple_touch_icon',
|
||||
'default_opengraph_image_url' => 'opengraph_image',
|
||||
'twitter_summary_large_image_url' => 'twitter_summary_large_image',
|
||||
'push_notifications_icon_url' => 'push_notifications_icon'
|
||||
}.each do |old_name, new_name|
|
||||
if DB.query_single("SELECT 1 FROM site_settings WHERE name = '#{old_name}' AND value IS NULL").present? &&
|
||||
DB.query_single("SELECT 1 FROM site_settings WHERE name = '#{new_name}'").empty?
|
||||
|
||||
ActiveRecord::Base.connection.execute <<~SQL
|
||||
INSERT INTO site_settings (
|
||||
name,
|
||||
data_type,
|
||||
value,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
'#{new_name}',
|
||||
18,
|
||||
'',
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user