mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
feat: Add admin contacts validation settings migration
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.
This commit is contained in:
parent
f2978599b4
commit
dc37223bc2
2 changed files with 101 additions and 2 deletions
|
@ -0,0 +1,48 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue