Merge pull request #10574 from opf/fix/restore-defaults-on-empty-setting-values

Restore defaults on empty setting values
pull/10581/head
Markus Kahl 3 years ago committed by GitHub
commit fc2d22820c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      db/migrate/20220428071221_restore_defaults_on_empty_settings.rb

@ -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…
Cancel
Save