20190314181829_migrate_open_registrations_setting.rb 646 B

123456789101112131415
  1. class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2]
  2. def up
  3. open_registrations = Setting.find_by(var: 'open_registrations')
  4. return if open_registrations.nil? || open_registrations.value
  5. setting = Setting.where(var: 'registrations_mode').first_or_initialize(var: 'registrations_mode')
  6. setting.update(value: 'none')
  7. end
  8. def down
  9. registrations_mode = Setting.find_by(var: 'registrations_mode')
  10. return if registrations_mode.nil?
  11. setting = Setting.where(var: 'open_registrations').first_or_initialize(var: 'open_registrations')
  12. setting.update(value: registrations_mode.value == 'open')
  13. end
  14. end