20190314181829_migrate_open_registrations_setting.rb 679 B

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