Skip to content

Commit

Permalink
feat: Add admin contacts validation settings migration
Browse files Browse the repository at this point in the history
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
OlegPhenomenon committed Feb 4, 2025
1 parent f297859 commit dc37223
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 2 deletions.
48 changes: 48 additions & 0 deletions db/migrate/20250204094550_add_admin_contacts_rules_to_settings.rb
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
55 changes: 53 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,38 @@ CREATE SEQUENCE public.epp_sessions_id_seq
ALTER SEQUENCE public.epp_sessions_id_seq OWNED BY public.epp_sessions.id;


--
-- Name: free_domain_reservation_holders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.free_domain_reservation_holders (
id bigint NOT NULL,
user_unique_id character varying NOT NULL,
domain_names character varying[] DEFAULT '{}'::character varying[],
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);


--
-- Name: free_domain_reservation_holders_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.free_domain_reservation_holders_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


--
-- Name: free_domain_reservation_holders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.free_domain_reservation_holders_id_seq OWNED BY public.free_domain_reservation_holders.id;


--
-- Name: invoice_items; Type: TABLE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2675,7 +2707,8 @@ CREATE TABLE public.reserved_domains (
updator_str character varying,
legacy_id integer,
name character varying NOT NULL,
password character varying NOT NULL
password character varying NOT NULL,
expire_at timestamp without time zone
);


Expand Down Expand Up @@ -3185,6 +3218,13 @@ ALTER TABLE ONLY public.epp_logs ALTER COLUMN id SET DEFAULT nextval('public.epp
ALTER TABLE ONLY public.epp_sessions ALTER COLUMN id SET DEFAULT nextval('public.epp_sessions_id_seq'::regclass);


--
-- Name: free_domain_reservation_holders id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.free_domain_reservation_holders ALTER COLUMN id SET DEFAULT nextval('public.free_domain_reservation_holders_id_seq'::regclass);


--
-- Name: invoice_items id; Type: DEFAULT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -3714,6 +3754,14 @@ ALTER TABLE ONLY public.epp_sessions
ADD CONSTRAINT epp_sessions_pkey PRIMARY KEY (id);


--
-- Name: free_domain_reservation_holders free_domain_reservation_holders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.free_domain_reservation_holders
ADD CONSTRAINT free_domain_reservation_holders_pkey PRIMARY KEY (id);


--
-- Name: invoice_items invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -5667,6 +5715,9 @@ INSERT INTO "schema_migrations" (version) VALUES
('20241030095636'),
('20241104104620'),
('20241112093540'),
('20241112124405');
('20241112124405'),
('20241129095711'),
('20241206085817'),
('20250204094550');


0 comments on commit dc37223

Please sign in to comment.