-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
f297859
commit dc37223
Showing
2 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
db/migrate/20250204094550_add_admin_contacts_rules_to_settings.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters