From dc37223bc28ad4edee2925ffd3f62e90144efe34 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Tue, 4 Feb 2025 11:47:41 +0200 Subject: [PATCH] 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. --- ...50_add_admin_contacts_rules_to_settings.rb | 48 ++++++++++++++++ db/structure.sql | 55 ++++++++++++++++++- 2 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20250204094550_add_admin_contacts_rules_to_settings.rb diff --git a/db/migrate/20250204094550_add_admin_contacts_rules_to_settings.rb b/db/migrate/20250204094550_add_admin_contacts_rules_to_settings.rb new file mode 100644 index 000000000..d585ca26f --- /dev/null +++ b/db/migrate/20250204094550_add_admin_contacts_rules_to_settings.rb @@ -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 diff --git a/db/structure.sql b/db/structure.sql index 9653f454e..b0e725a9e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -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: - -- @@ -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 ); @@ -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: - -- @@ -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: - -- @@ -5667,6 +5715,9 @@ INSERT INTO "schema_migrations" (version) VALUES ('20241030095636'), ('20241104104620'), ('20241112093540'), -('20241112124405'); +('20241112124405'), +('20241129095711'), +('20241206085817'), +('20250204094550');