2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-24 09:30:00 +08:00
|
|
|
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
|