diff --git a/app/controllers/repp/v1/domains/contacts_controller.rb b/app/controllers/repp/v1/domains/contacts_controller.rb
index 4c89243c7..b41b3a378 100644
--- a/app/controllers/repp/v1/domains/contacts_controller.rb
+++ b/app/controllers/repp/v1/domains/contacts_controller.rb
@@ -14,8 +14,8 @@ module Repp
api :GET, '/repp/v1/domains/:domain_name/contacts'
desc "View domain's admin and tech contacts"
def index
- admin_contacts = @domain.admin_domain_contacts.pluck(:contact_code_cache)
- tech_contacts = @domain.tech_domain_contacts.pluck(:contact_code_cache)
+ admin_contacts = @domain.admin_domain_contacts.map(&:contact).pluck(:code)
+ tech_contacts = @domain.tech_domain_contacts.map(&:contact).pluck(:code)
data = { admin_contacts: admin_contacts, tech_contacts: tech_contacts }
render_success(data: data)
@@ -38,7 +38,6 @@ module Repp
def cta(action = 'add')
params[:contacts].each { |c| c[:action] = action }
action = Actions::DomainUpdate.new(@domain, contact_create_params, false)
-
# rubocop:disable Style/AndOr
handle_errors(@domain) and return unless action.call
# rubocop:enable Style/AndOr
diff --git a/app/interactions/actions/domain_create.rb b/app/interactions/actions/domain_create.rb
index 8fd25df0f..a60e0e635 100644
--- a/app/interactions/actions/domain_create.rb
+++ b/app/interactions/actions/domain_create.rb
@@ -120,7 +120,7 @@ module Actions
contact = Contact.find_by(code: contact_code)
arr = admin ? @admin_contacts : @tech_contacts
if contact
- arr << { contact_id: contact.id, contact_code_cache: contact.code }
+ arr << { contact_id: contact.id }
else
domain.add_epp_error('2303', 'contact', contact_code, %i[domain_contacts not_found])
end
diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb
index 3c408e11f..5508f641e 100644
--- a/app/interactions/actions/domain_update.rb
+++ b/app/interactions/actions/domain_update.rb
@@ -125,8 +125,7 @@ module Actions
end
def start_validate_email(props)
- contact_code = props[0][:contact_code_cache]
- contact = Contact.find_by(code: contact_code)
+ contact = Contact.find(props[0][:contact_id])
return if contact.nil?
@@ -206,7 +205,7 @@ module Actions
domain.add_epp_error('2306', 'contact', code,
%i[domain_contacts admin_contact_can_be_only_private_person])
else
- add ? { contact_id: obj.id, contact_code_cache: obj.code } : { id: obj.id, _destroy: 1 }
+ add ? { contact_id: obj.id } : { id: obj.id, _destroy: 1 }
end
end
diff --git a/app/models/domain.rb b/app/models/domain.rb
index 4d7a4e706..68c5bc611 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -161,14 +161,6 @@ class Domain < ApplicationRecord
attribute: 'hostname'
}
- validates :tech_domain_contacts, uniqueness_multi: {
- attribute: 'contact_code_cache'
- }
-
- validates :admin_domain_contacts, uniqueness_multi: {
- attribute: 'contact_code_cache'
- }
-
validates :dnskeys, uniqueness_multi: {
attribute: 'public_key'
}
diff --git a/app/models/domain_contact.rb b/app/models/domain_contact.rb
index 910f4e445..1f85d9242 100644
--- a/app/models/domain_contact.rb
+++ b/app/models/domain_contact.rb
@@ -6,32 +6,20 @@ class DomainContact < ApplicationRecord
belongs_to :contact
belongs_to :domain
+ validates :contact, presence: true
+
+ after_destroy :update_contact
attr_accessor :value_typeahead
self.ignored_columns = %w[legacy_domain_id legacy_contact_id]
- def epp_code_map
- {
- '2302' => [
- [:contact_code_cache, :taken, { value: { obj: 'contact', val: contact_code_cache } }]
- ]
- }
- end
-
def name
return 'Tech' if type == 'TechDomainContact'
return 'Admin' if type == 'AdminDomainContact'
+
''
end
- validates :contact, presence: true
-
- before_save :update_contact_code_cache
- def update_contact_code_cache
- self.contact_code_cache = contact.code
- end
-
- after_destroy :update_contact
def update_contact
Contact.find(contact_id).save
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c36dcadeb..9c396cbde 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -96,8 +96,6 @@ en:
contact:
blank: 'Contact was not found'
taken: 'Contact already exists on this domain'
- contact_code_cache:
- taken: 'Contact already exists on this domain'
domain_status:
attributes:
@@ -628,7 +626,7 @@ en:
contact_ident: 'Contact ident'
results_per_page: 'Results per page'
nameserver_hostname: 'Nameserver hostname'
- result_count:
+ result_count:
zero: 'No results'
other: '%{count} results'
one: '1 result'
diff --git a/db/migrate/20141210085432_add_code_cache_for_domain_contact.rb b/db/migrate/20141210085432_add_code_cache_for_domain_contact.rb
index c3c71ff35..d3aac8296 100644
--- a/db/migrate/20141210085432_add_code_cache_for_domain_contact.rb
+++ b/db/migrate/20141210085432_add_code_cache_for_domain_contact.rb
@@ -1,10 +1,10 @@
class AddCodeCacheForDomainContact < ActiveRecord::Migration[6.0]
def change
- add_column :domain_contacts, :contact_code_cache, :string
-
- DomainContact.all.each do |x|
- x.contact_code_cache = x.contact.code
- x.save
- end
+ # add_column :domain_contacts, :contact_code_cache, :string
+ #
+ # DomainContact.all.each do |x|
+ # x.contact_code_cache = x.contact.code
+ # x.save
+ # end
end
end
diff --git a/db/migrate/20220504090512_remove_contact_code_cache_from_domain_contacts.rb b/db/migrate/20220504090512_remove_contact_code_cache_from_domain_contacts.rb
new file mode 100644
index 000000000..98129b933
--- /dev/null
+++ b/db/migrate/20220504090512_remove_contact_code_cache_from_domain_contacts.rb
@@ -0,0 +1,5 @@
+class RemoveContactCodeCacheFromDomainContacts < ActiveRecord::Migration[6.1]
+ def change
+ # remove_column :domain_contacts, :contact_code_cache
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index f6f906d17..76eccf8a7 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -51,6 +51,20 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
+--
+-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
+--
+
+CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
+
+
+--
+-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: -
+--
+
+COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
+
+
--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
@@ -848,7 +862,6 @@ CREATE TABLE public.domain_contacts (
domain_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone,
- contact_code_cache character varying,
creator_str character varying,
updator_str character varying,
type character varying,
@@ -1091,7 +1104,6 @@ CREATE TABLE public.invoices (
buyer_vat_no character varying,
issue_date date NOT NULL,
e_invoice_sent_at timestamp without time zone,
- payment_link character varying,
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
);
@@ -5083,13 +5095,13 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220106123143'),
('20220113201642'),
('20220113220809'),
+('20220228093211'),
('20220316140727'),
('20220406085500'),
+('20220412130856'),
('20220413073315'),
('20220413084536'),
('20220413084748'),
-('20220124105717'),
-('20220216113112'),
-('20220228093211'),
-('20220412130856');
+('20220504090512');
+
diff --git a/doc/epp_examples.md b/doc/epp_examples.md
index 7e0e001ba..bd4e78b9a 100644
--- a/doc/epp_examples.md
+++ b/doc/epp_examples.md
@@ -9980,7 +9980,7 @@ RESPONSE:
- Contact already exists on this domain [contact_code_cache]
+ Contact already exists on this domain [contact_code]
FIXED:MAK21
@@ -10505,7 +10505,7 @@ RESPONSE:
- Contact already exists on this domain [contact_code_cache]
+ Contact already exists on this domain [contact_code]
FIXED:SH6021836789
@@ -14058,4 +14058,3 @@ RESPONSE:
```
-
diff --git a/lib/serializers/repp/domain.rb b/lib/serializers/repp/domain.rb
index 6547f21b8..d365859c1 100644
--- a/lib/serializers/repp/domain.rb
+++ b/lib/serializers/repp/domain.rb
@@ -23,7 +23,7 @@ module Serializers
# rubocop:enable Metrics/AbcSize
def contacts
- domain.domain_contacts.map { |c| { code: c.contact_code_cache, type: c.type } }
+ domain.domain_contacts.map { |c| { code: c.contact.code, type: c.type } }
end
def nameservers