mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: only migrate SiteText to SiteCustomization if there are any
This commit is contained in:
parent
1a6cbd37a5
commit
9156d6cd9d
1 changed files with 19 additions and 12 deletions
|
@ -2,9 +2,13 @@ class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration
|
|||
|
||||
def up
|
||||
execute <<-SQL
|
||||
INSERT INTO site_customizations
|
||||
(name, user_id, enabled, key, created_at, updated_at, head_tag, body_tag)
|
||||
VALUES (
|
||||
DO
|
||||
$do$
|
||||
BEGIN
|
||||
IF EXISTS(SELECT 1 FROM site_texts WHERE (text_type = 'head' OR text_type = 'bottom')) THEN
|
||||
INSERT INTO site_customizations (name, user_id, enabled, key, created_at, updated_at, head_tag, body_tag)
|
||||
VALUES
|
||||
(
|
||||
'Migrated from Site Text',
|
||||
-1,
|
||||
't',
|
||||
|
@ -13,7 +17,10 @@ class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration
|
|||
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
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue