You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
646 B

  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