mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
31 lines
922 B
Ruby
31 lines
922 B
Ruby
# frozen_string_literal: true
|
|
|
|
class GlitchMigrateDefaultSkinSetting < ActiveRecord::Migration[8.0]
|
|
class Setting < ApplicationRecord; end
|
|
|
|
def up
|
|
Setting.reset_column_information
|
|
|
|
return unless %w(glitch vanilla).include?(flavour)
|
|
|
|
setting = Setting.find_by(var: 'skin')
|
|
return unless setting.present? && setting.attributes['value'].present?
|
|
|
|
theme = YAML.safe_load(setting.attributes['value'], permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol])
|
|
return unless %w(mastodon-light contrast system).include?(theme)
|
|
|
|
setting.update_column('value', "--- default\n")
|
|
end
|
|
|
|
def down; end
|
|
|
|
private
|
|
|
|
def flavour
|
|
setting = Setting.find_by(var: 'flavour')
|
|
return 'glitch' unless setting.present? && setting.attributes['value'].present?
|
|
|
|
YAML.safe_load(setting.attributes['value'], permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol])
|
|
end
|
|
end
|