move SiteText.{head,top,bottom} to SiteCustomization

This commit is contained in:
Régis Hanol
2015-01-14 11:52:42 +01:00
parent df5d81d7b4
commit 6734a51b6a
14 changed files with 132 additions and 59 deletions

View File

@@ -11,7 +11,7 @@ class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration
'#{SecureRandom.uuid}',
now(),
now(),
(SELECT value FROM site_texts WHERE text_type = 'top' LIMIT 1),
(SELECT value FROM site_texts WHERE text_type = 'head' LIMIT 1),
(SELECT value FROM site_texts WHERE text_type = 'bottom' LIMIT 1)
)
SQL

View File

@@ -0,0 +1,20 @@
class AddTopToSiteCustomization < ActiveRecord::Migration
def up
add_column :site_customizations, :top, :text
add_column :site_customizations, :mobile_top, :text
execute <<-SQL
UPDATE site_customizations
SET top = (SELECT value FROM site_texts WHERE text_type = 'top' LIMIT 1),
mobile_top = (SELECT value FROM site_texts WHERE text_type = 'top' LIMIT 1),
head_tag = (SELECT value FROM site_texts WHERE text_type = 'head' LIMIT 1),
body_tag = (SELECT value FROM site_texts WHERE text_type = 'bottom' LIMIT 1)
WHERE name = 'Migrated from Site Text'
SQL
end
def down
remove_column :site_customizations, :top
remove_column :site_customizations, :mobile_top
end
end