Merge pull request #10574 from opf/fix/restore-defaults-on-empty-setting-values
Restore defaults on empty setting valuespull/10581/head
commit
fc2d22820c
@ -0,0 +1,22 @@ |
||||
class RestoreDefaultsOnEmptySettings < ActiveRecord::Migration[6.1] |
||||
def up |
||||
settings = Setting.where(value: '') |
||||
|
||||
settings.find_each do |setting| |
||||
definition = Settings::Definition[setting.name] |
||||
|
||||
if definition.nil? |
||||
warn "Did not find definition for #{setting.name}. This setting is probably outdated an can be removed." |
||||
next |
||||
end |
||||
|
||||
next if definition.value == '' |
||||
|
||||
setting.update_column(:value, definition.value) |
||||
end |
||||
end |
||||
|
||||
def down |
||||
# Nothing to do |
||||
end |
||||
end |
Loading…
Reference in new issue