mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 13:31:44 +08:00
FIX: only migrate SiteText to SiteCustomization if there are any
This commit is contained in:
parent
1a6cbd37a5
commit
9156d6cd9d
|
@ -2,18 +2,25 @@ class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration
|
||||||
|
|
||||||
def up
|
def up
|
||||||
execute <<-SQL
|
execute <<-SQL
|
||||||
INSERT INTO site_customizations
|
DO
|
||||||
(name, user_id, enabled, key, created_at, updated_at, head_tag, body_tag)
|
$do$
|
||||||
VALUES (
|
BEGIN
|
||||||
'Migrated from Site Text',
|
IF EXISTS(SELECT 1 FROM site_texts WHERE (text_type = 'head' OR text_type = 'bottom')) THEN
|
||||||
-1,
|
INSERT INTO site_customizations (name, user_id, enabled, key, created_at, updated_at, head_tag, body_tag)
|
||||||
't',
|
VALUES
|
||||||
'#{SecureRandom.uuid}',
|
(
|
||||||
now(),
|
'Migrated from Site Text',
|
||||||
now(),
|
-1,
|
||||||
(SELECT value FROM site_texts WHERE text_type = 'head' LIMIT 1),
|
't',
|
||||||
(SELECT value FROM site_texts WHERE text_type = 'bottom' LIMIT 1)
|
'#{SecureRandom.uuid}',
|
||||||
)
|
now(),
|
||||||
|
now(),
|
||||||
|
(SELECT value FROM site_texts WHERE text_type = 'head' LIMIT 1),
|
||||||
|
(SELECT value FROM site_texts WHERE text_type = 'bottom' LIMIT 1)
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$do$
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user