2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration[4.2]
|
2015-01-12 13:59:43 -05:00
|
|
|
|
|
|
|
def up
|
|
|
|
execute <<-SQL
|
2015-08-07 10:30:30 -04:00
|
|
|
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',
|
|
|
|
'#{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$
|
2015-01-12 13:59:43 -05:00
|
|
|
SQL
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|