mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 22:16:19 +02:00
Add migration to create new settings for admin contacts validation: - admin_contacts_required_for_org: boolean setting to require admin contacts for organizations - admin_contacts_required_for_minors: boolean setting to require admin contacts for minors - admin_contacts_allowed_ident_type: array setting to specify allowed identification types for admin contacts The migration safely handles existing settings by checking for their presence before creation. Default values are set to maintain backwards compatibility while enforcing new validation rules.
48 lines
1.4 KiB
Ruby
48 lines
1.4 KiB
Ruby
class AddAdminContactsRulesToSettings < ActiveRecord::Migration[6.1]
|
|
def up
|
|
unless SettingEntry.exists?(code: 'admin_contacts_required_for_org')
|
|
SettingEntry.create!(
|
|
code: 'admin_contacts_required_for_org',
|
|
value: 'true',
|
|
format: 'boolean',
|
|
group: 'domain_validation'
|
|
)
|
|
else
|
|
puts "SettingEntry admin_contacts_required_for_org already exists"
|
|
end
|
|
|
|
unless SettingEntry.exists?(code: 'admin_contacts_required_for_minors')
|
|
SettingEntry.create!(
|
|
code: 'admin_contacts_required_for_minors',
|
|
value: 'true',
|
|
format: 'boolean',
|
|
group: 'domain_validation'
|
|
)
|
|
else
|
|
puts "SettingEntry admin_contacts_required_for_minors already exists"
|
|
end
|
|
|
|
unless SettingEntry.exists?(code: 'admin_contacts_allowed_ident_type')
|
|
SettingEntry.create!(
|
|
code: 'admin_contacts_allowed_ident_type',
|
|
value: {
|
|
'birthday' => true,
|
|
'priv' => true,
|
|
'org' => false
|
|
}.to_json,
|
|
format: 'array',
|
|
group: 'domain_validation'
|
|
)
|
|
else
|
|
puts "SettingEntry admin_contacts_allowed_ident_type already exists"
|
|
end
|
|
end
|
|
|
|
def down
|
|
SettingEntry.where(code: [
|
|
'admin_contacts_required_for_org',
|
|
'admin_contacts_required_for_minors',
|
|
'admin_contacts_allowed_ident_type'
|
|
]).destroy_all
|
|
end
|
|
end
|