discourse/db/migrate/20180813074843_add_component_to_themes.rb
Osama Sayegh e0cc29d658 FEATURE: themes and components split
* FEATURE: themes and components split

* two seperate methods to switch theme type

* use strict equality operator
2018-08-24 11:30:00 +10:00

27 lines
679 B
Ruby

class AddComponentToThemes < ActiveRecord::Migration[5.2]
def up
add_column :themes, :component, :boolean, null: false, default: false
execute("
UPDATE themes
SET component = true, color_scheme_id = NULL, user_selectable = false
WHERE id IN (SELECT child_theme_id FROM child_themes)
")
execute("
UPDATE site_settings
SET value = -1
WHERE name = 'default_theme_id' AND value::integer IN (SELECT id FROM themes WHERE component)
")
execute("
DELETE FROM child_themes
WHERE parent_theme_id IN (SELECT id FROM themes WHERE component)
")
end
def down
remove_column :themes, :component
end
end