From 487613db1eb5125172f2f077a375048c7c1b83db Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 28 Mar 2019 22:08:16 +0200 Subject: [PATCH 01/18] Refactor inactive contact archivation Fixes #956 --- app/models/concerns/contact/archivable.rb | 38 +++++++ app/models/contact.rb | 66 ++++------- app/models/inactive_contacts.rb | 14 +++ app/models/version/domain_version.rb | 39 ++++++- config/schedule.rb | 2 +- lib/tasks/contacts/archive.rake | 14 +++ spec/models/contact_spec.rb | 28 ----- .../previews/contact_mailer_preview.rb | 7 +- test/models/contact/archivable_test.rb | 81 ++++++++++++++ test/models/contact_test.rb | 54 ++++++++- test/models/inactive_contacts_test.rb | 13 +++ test/models/version/domain_version_test.rb | 105 ++++++++++++++++++ test/tasks/contacts/archive_test.rb | 46 ++++++++ test/test_helper.rb | 1 + 14 files changed, 424 insertions(+), 84 deletions(-) create mode 100644 app/models/concerns/contact/archivable.rb create mode 100644 app/models/inactive_contacts.rb create mode 100644 lib/tasks/contacts/archive.rake create mode 100644 test/models/contact/archivable_test.rb create mode 100644 test/models/inactive_contacts_test.rb create mode 100644 test/models/version/domain_version_test.rb create mode 100644 test/tasks/contacts/archive_test.rb diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb new file mode 100644 index 000000000..c2a8ca103 --- /dev/null +++ b/app/models/concerns/contact/archivable.rb @@ -0,0 +1,38 @@ +module Concerns + module Contact + module Archivable + extend ActiveSupport::Concern + + included do + class_attribute :inactivity_period, instance_predicate: false, instance_writer: false + self.inactivity_period = Setting.orphans_contacts_in_months.months + end + + class_methods do + def archivable + unlinked.find_each.select(&:archivable?) + end + end + + def archivable? + inactive? + end + + def archive + raise 'Contact cannot be archived' unless archivable? + destroy! + end + + private + + def inactive? + if DomainVersion.was_contact_linked?(self) + DomainVersion.contact_unlinked_more_than?(contact: self, + period: inactivity_period) + else + created_at <= inactivity_period.ago + end + end + end + end +end \ No newline at end of file diff --git a/app/models/contact.rb b/app/models/contact.rb index 06407ae69..127630ac8 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -5,6 +5,7 @@ class Contact < ActiveRecord::Base include Concerns::Contact::Transferable include Concerns::Contact::Identical include Concerns::Contact::Disclosable + include Concerns::Contact::Archivable belongs_to :original, class_name: self.name belongs_to :registrar, required: true @@ -144,61 +145,17 @@ class Contact < ActiveRecord::Base res.reduce([]) { |o, v| o << { id: v[:id], display_key: "#{v.name} (#{v.code})" } } end - def find_orphans - where(' - NOT EXISTS( - select 1 from domains d where d.registrant_id = contacts.id - ) AND NOT EXISTS( - select 1 from domain_contacts dc where dc.contact_id = contacts.id - ) - ') - end - - def find_linked - where(' - EXISTS( - select 1 from domains d where d.registrant_id = contacts.id - ) OR EXISTS( - select 1 from domain_contacts dc where dc.contact_id = contacts.id - ) - ') - end - def filter_by_states in_states states = Array(in_states).dup scope = all # all contacts has state ok, so no need to filter by it scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}") if states.delete(OK) - scope = scope.find_linked if states.delete(LINKED) + scope = scope.linked if states.delete(LINKED) scope = scope.where("contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any? scope end - # To leave only new ones we need to check - # if contact was at any time used in domain. - # This can be checked by domain history. - # This can be checked by saved relations in children attribute - def destroy_orphans - STDOUT << "#{Time.zone.now.utc} - Destroying orphaned contacts\n" unless Rails.env.test? - - counter = Counter.new - find_orphans.find_each do |contact| - ver_scope = [] - %w(admin_contacts tech_contacts registrant).each do |type| - ver_scope << "(children->'#{type}')::jsonb <@ json_build_array(#{contact.id})::jsonb" - end - next if DomainVersion.where("created_at > ?", Time.now - Setting.orphans_contacts_in_months.to_i.months).where(ver_scope.join(" OR ")).any? - next if contact.linked? - - contact.destroy - counter.next - STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{contact.id} (#{contact.name})\n" unless Rails.env.test? - end - - STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{counter} orphaned contacts\n" unless Rails.env.test? - end - def admin_statuses [ SERVER_UPDATE_PROHIBITED, @@ -257,6 +214,23 @@ class Contact < ActiveRecord::Base .country.alpha2) end + def linked + sql = <<-SQL + EXISTS(SELECT 1 FROM domains WHERE domains.registrant_id = contacts.id) OR + EXISTS(SELECT 1 FROM domain_contacts WHERE domain_contacts.contact_id = + contacts.id) + SQL + + where(sql) + end + + def unlinked + where('NOT EXISTS(SELECT 1 FROM domains WHERE domains.registrant_id = contacts.id) + AND + NOT EXISTS(SELECT 1 FROM domain_contacts WHERE domain_contacts.contact_id = + contacts.id)') + end + private def registrant_user_indirect_contacts(registrant_user) @@ -557,4 +531,4 @@ class Contact < ActiveRecord::Base def deletable? !linked? end -end +end \ No newline at end of file diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb new file mode 100644 index 000000000..a1ccda205 --- /dev/null +++ b/app/models/inactive_contacts.rb @@ -0,0 +1,14 @@ +class InactiveContacts + attr_reader :contacts + + def initialize(contacts = Contact.archivable) + @contacts = contacts + end + + def archive + contacts.each do |contact| + contact.archive + yield contact if block_given? + end + end +end \ No newline at end of file diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb index 2986d7811..c7a5618db 100644 --- a/app/models/version/domain_version.rb +++ b/app/models/version/domain_version.rb @@ -5,4 +5,41 @@ class DomainVersion < PaperTrail::Version self.sequence_name = :log_domains_id_seq scope :deleted, -> { where(event: 'destroy') } -end + + def self.was_contact_linked?(contact) + sql = <<-SQL + SELECT + COUNT(*) + FROM + #{table_name} + WHERE + (children->'registrant') @> '#{contact.id}' + OR + (children->'admin_contacts') @> '#{contact.id}' + OR + (children->'tech_contacts') @> '#{contact.id}' + SQL + + count_by_sql(sql).nonzero? + end + + def self.contact_unlinked_more_than?(contact:, period:) + sql = <<-SQL + SELECT + COUNT(*) + FROM + #{table_name} + WHERE + created_at < TIMESTAMP WITH TIME ZONE '#{period.ago}' + AND ( + (children->'registrant') @> '#{contact.id}' + OR + (children->'admin_contacts') @> '#{contact.id}' + OR + (children->'tech_contacts') @> '#{contact.id}' + ) + SQL + + count_by_sql(sql).nonzero? + end +end \ No newline at end of file diff --git a/config/schedule.rb b/config/schedule.rb index d47b45ea9..6eb3db307 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -18,7 +18,7 @@ if @cron_group == 'registry' end every 6.months, at: '12:01am' do - runner 'Contact.destroy_orphans' + rake 'contacts:archive' end every :day, at: '12:10am' do diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake new file mode 100644 index 000000000..1778be98b --- /dev/null +++ b/lib/tasks/contacts/archive.rake @@ -0,0 +1,14 @@ +namespace :contacts do + desc 'Archives inactive contacts' + + task archive: :environment do + inactive_contacts = InactiveContacts.new + archived_contacts = inactive_contacts.archive + + archived_contacts.each do |contact| + puts "Contact ##{contact.id} (code: #{contact.code}) is archived" + end + + puts "Archived total: #{archived_contacts.count}" + end +end \ No newline at end of file diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 52469b28f..cfcdad30e 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -185,34 +185,6 @@ RSpec.describe Contact do end end -describe Contact, '.destroy_orphans' do - before do - create(:zone, origin: 'ee') - @contact_1 = create(:contact, code: 'asd12') - @contact_2 = create(:contact, code: 'asd13') - end - - it 'destroys orphans' do - Contact.find_orphans.count.should == 2 - Contact.destroy_orphans - Contact.find_orphans.count.should == 0 - end - - it 'should find one orphan' do - create(:domain, registrant: Registrant.find(@contact_1.id)) - Contact.find_orphans.count.should == 1 - Contact.find_orphans.last.should == @contact_2 - end - - it 'should find no orphans' do - create(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2]) - cc = Contact.count - Contact.find_orphans.count.should == 0 - Contact.destroy_orphans - Contact.count.should == cc - end -end - RSpec.describe Contact do it { is_expected.to alias_attribute(:kind, :ident_type) } diff --git a/test/mailers/previews/contact_mailer_preview.rb b/test/mailers/previews/contact_mailer_preview.rb index 1e00ef673..6186f108a 100644 --- a/test/mailers/previews/contact_mailer_preview.rb +++ b/test/mailers/previews/contact_mailer_preview.rb @@ -1,11 +1,6 @@ class ContactMailerPreview < ActionMailer::Preview def email_changed - # Replace with `Contact.in_use` once https://github.com/internetee/registry/pull/1146 is merged - contact = Contact.where('EXISTS(SELECT 1 FROM domains WHERE domains.registrant_id = contacts.id) - OR - EXISTS(SELECT 1 FROM domain_contacts WHERE domain_contacts.contact_id = - contacts.id)') - + contact = Contact.linked contact = contact.where.not(email: nil, country_code: nil, code: nil).first ContactMailer.email_changed(contact: contact, old_email: 'old@inbox.test') diff --git a/test/models/contact/archivable_test.rb b/test/models/contact/archivable_test.rb new file mode 100644 index 000000000..ebd3b2d12 --- /dev/null +++ b/test/models/contact/archivable_test.rb @@ -0,0 +1,81 @@ +require 'test_helper' + +class ArchivableContactTest < ActiveSupport::TestCase + setup do + @contact = contacts(:john) + end + + def test_contact_is_archivable_when_it_was_linked_and_inactivity_period_has_passed + DomainVersion.stub(:was_contact_linked?, true) do + DomainVersion.stub(:contact_unlinked_more_than?, true) do + assert @contact.archivable? + end + end + end + + def test_contact_is_archivable_when_it_was_never_linked_and_inactivity_period_has_passed + Contact.inactivity_period = 1.second + @contact.created_at = Time.zone.parse('2010-07-05 00:00:00') + travel_to Time.zone.parse('2010-07-05 00:00:01') + + DomainVersion.stub(:was_contact_linked?, false) do + assert @contact.archivable? + end + end + + def test_contact_is_not_archivable_when_it_was_never_linked_and_inactivity_period_has_not_passed + Contact.inactivity_period = 1.second + @contact.created_at = Time.zone.parse('2010-07-05') + travel_to Time.zone.parse('2010-07-05') + + DomainVersion.stub(:contact_unlinked_more_than?, false) do + assert_not @contact.archivable? + end + end + + def test_contact_is_not_archivable_when_it_was_ever_linked_but_linked_within_inactivity_period + DomainVersion.stub(:was_contact_linked?, true) do + DomainVersion.stub(:contact_unlinked_more_than?, false) do + assert_not @contact.archivable? + end + end + end + + def test_archives_contact + contact = archivable_contact + + assert_difference 'Contact.count', -1 do + contact.archive + end + end + + def test_unarchivable_contact_cannot_be_archived + contact = unarchivable_contact + + e = assert_raises do + contact.archive + end + assert_equal 'Contact cannot be archived', e.message + end + + private + + def archivable_contact + contact = contacts(:john) + Contact.inactivity_period = 0.seconds + DomainVersion.delete_all + + other_contact = contacts(:william) + assert_not_equal other_contact, contact + Domain.update_all(registrant_id: other_contact) + + DomainContact.delete_all + + contact + end + + def unarchivable_contact + Contact.inactivity_period = 99.years + @contact + end +end \ No newline at end of file diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index 9c05e9d1d..2e0a463ec 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -133,6 +133,52 @@ class ContactTest < ActiveSupport::TestCase assert_not @contact.deletable? end + def test_linked_scope_returns_contact_that_acts_as_registrant + domains(:shop).update!(registrant: @contact.becomes(Registrant)) + assert Contact.linked.include?(@contact), 'Contact should be included' + end + + def test_linked_scope_returns_contact_that_acts_as_admin_contact + domains(:shop).admin_contacts = [@contact] + assert Contact.linked.include?(@contact), 'Contact should be included' + end + + def test_linked_scope_returns_contact_that_acts_as_tech_contact + domains(:shop).tech_contacts = [@contact] + assert Contact.linked.include?(@contact), 'Contact should be included' + end + + def test_linked_scope_skips_unlinked_contact + contact = unlinked_contact + assert_not Contact.linked.include?(contact), 'Contact should be excluded' + end + + def test_unlinked_scope_returns_unlinked_contact + contact = unlinked_contact + assert Contact.unlinked.include?(contact), 'Contact should be included' + end + + def test_unlinked_scope_skips_contact_that_is_linked_as_registrant + contact = unlinked_contact + domains(:shop).update_columns(registrant_id: contact.becomes(Registrant)) + + assert Contact.unlinked.exclude?(contact), 'Contact should be excluded' + end + + def test_unlinked_scope_skips_contact_that_is_linked_as_admin_contact + contact = unlinked_contact + domains(:shop).admin_contacts = [contact] + + assert Contact.unlinked.exclude?(contact), 'Contact should be excluded' + end + + def test_unlinked_scope_skips_contact_that_is_linked_as_tech_contact + contact = unlinked_contact + domains(:shop).tech_contacts = [contact] + + assert Contact.unlinked.exclude?(contact), 'Contact should be excluded' + end + private def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact) @@ -142,8 +188,12 @@ class ContactTest < ActiveSupport::TestCase end def unlinked_contact - Domain.update_all(registrant_id: contacts(:william)) + other_contact = contacts(:william) + assert_not_equal @contact, other_contact + Domain.update_all(registrant_id: other_contact) + DomainContact.delete_all - contacts(:john) + + @contact end end \ No newline at end of file diff --git a/test/models/inactive_contacts_test.rb b/test/models/inactive_contacts_test.rb new file mode 100644 index 000000000..eb0d23b3b --- /dev/null +++ b/test/models/inactive_contacts_test.rb @@ -0,0 +1,13 @@ +require 'test_helper' + +class InactiveContactsTest < ActiveSupport::TestCase + def test_archives_inactive_contacts + contact_mock = Minitest::Mock.new + contact_mock.expect(:archive, nil) + + inactive_contacts = InactiveContacts.new([contact_mock]) + inactive_contacts.archive + + assert_mock contact_mock + end +end \ No newline at end of file diff --git a/test/models/version/domain_version_test.rb b/test/models/version/domain_version_test.rb new file mode 100644 index 000000000..801705432 --- /dev/null +++ b/test/models/version/domain_version_test.rb @@ -0,0 +1,105 @@ +require 'test_helper' + +class DomainVersionTest < ActiveSupport::TestCase + setup do + @domain_version = log_domains(:one) + @contact = contacts(:john) + end + + def test_was_contact_linked_returns_true_when_contact_was_used_as_registrant + @domain_version.update!(children: { admin_contacts: [], + tech_contacts: [], + registrant: [@contact.id] }) + + assert DomainVersion.was_contact_linked?(@contact) + end + + def test_was_contact_linked_returns_true_when_contact_was_used_as_admin_contact + @domain_version.update!(children: { admin_contacts: [@contact.id], + tech_contacts: [], + registrant: [] }) + + assert DomainVersion.was_contact_linked?(@contact) + end + + def test_was_contact_linked_returns_true_when_contact_was_used_as_tech_contact + @domain_version.update!(children: { admin_contacts: [], + tech_contacts: [@contact.id], + registrant: [] }) + + assert DomainVersion.was_contact_linked?(@contact) + end + + def test_was_contact_linked_returns_false_when_contact_was_not_used + @domain_version.update!(children: { admin_contacts: [], + tech_contacts: [], + registrant: [] }) + + assert_not DomainVersion.was_contact_linked?(@contact) + end + + def test_contact_unlinked_more_than_returns_true_when_contact_was_linked_as_registrant_more_than_given_period + @domain_version.update!(created_at: Time.zone.parse('2010-07-04 00:00:00'), + children: { admin_contacts: [], + tech_contacts: [], + registrant: [@contact.id] }) + travel_to Time.zone.parse('2010-07-05 00:00:01') + + assert DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end + + def test_contact_unlinked_more_than_given_period_as_admin_contact + @domain_version.update!(created_at: Time.zone.parse('2010-07-04 00:00:00'), + children: { admin_contacts: [1, @contact.id], + tech_contacts: [], + registrant: [] }) + travel_to Time.zone.parse('2010-07-05 00:00:01') + + assert DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end + + def test_contact_unlinked_more_than_given_period_as_tech_contact + @domain_version.update!(created_at: Time.zone.parse('2010-07-04 00:00:00'), + children: { admin_contacts: [], + tech_contacts: [1, @contact.id], + registrant: [] }) + travel_to Time.zone.parse('2010-07-05 00:00:01') + + assert DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end + + def test_contact_linked_within_given_period_as_registrant + @domain_version.update!(created_at: Time.zone.parse('2010-07-05'), + children: { admin_contacts: [], + tech_contacts: [], + registrant: [@contact.id] }) + travel_to Time.zone.parse('2010-07-05') + + assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end + + def test_contact_linked_within_given_period_as_admin_contact + @domain_version.update!(created_at: Time.zone.parse('2010-07-05'), + children: { admin_contacts: [1, @contact.id], + tech_contacts: [], + registrant: [] }) + travel_to Time.zone.parse('2010-07-05') + + assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end + + def test_contact_linked_within_given_period_as_tech_contact + @domain_version.update!(created_at: Time.zone.parse('2010-07-05'), + children: { admin_contacts: [], + tech_contacts: [1, @contact.id], + registrant: [] }) + travel_to Time.zone.parse('2010-07-05') + + assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end + + def test_contact_was_never_linked + DomainVersion.delete_all + assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + end +end \ No newline at end of file diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb new file mode 100644 index 000000000..54e7a6650 --- /dev/null +++ b/test/tasks/contacts/archive_test.rb @@ -0,0 +1,46 @@ +require 'test_helper' + +class ArchiveContactsTaskTest < ActiveSupport::TestCase + def test_archives_inactive_contacts + eliminate_effect_of_all_contacts_except(archivable_contact) + + assert_difference 'Contact.count', -1 do + capture_io { run_task } + end + end + + def test_output + contact = archivable_contact + eliminate_effect_of_all_contacts_except(contact) + + expected_output = "Contact ##{contact.id} (code: #{contact.code}) is archived\n" \ + "Archived total: 1\n" + assert_output(expected_output) { run_task } + end + + private + + def archivable_contact + contact = contacts(:john) + Contact.inactivity_period = 0.seconds + DomainVersion.delete_all + + other_contact = contacts(:william) + assert_not_equal other_contact, contact + Domain.update_all(registrant_id: other_contact) + + DomainContact.delete_all + + contact + end + + def eliminate_effect_of_all_contacts_except(contact) + Contact.connection.disable_referential_integrity do + Contact.delete_all("id != #{contact.id}") + end + end + + def run_task + Rake::Task['contacts:archive'].execute + end +end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index fba374d5b..92d82b86f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -33,6 +33,7 @@ class ActiveSupport::TestCase ActiveRecord::Migration.check_pending! fixtures :all + set_fixture_class log_domains: DomainVersion teardown do travel_back From d45e500e42e023bf40297166969b83da50dbfa4c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 2 Apr 2019 12:58:18 +0300 Subject: [PATCH 02/18] Archive contacts every day --- config/schedule.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/schedule.rb b/config/schedule.rb index 6eb3db307..88bf48c61 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -17,7 +17,7 @@ if @cron_group == 'registry' runner 'DNS::Zone.generate_zonefiles' end - every 6.months, at: '12:01am' do + every :day, at: '12:01am' do rake 'contacts:archive' end From 6659c597d7a4b274095be2449c811c929c33dbbb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 4 Apr 2019 18:21:08 +0300 Subject: [PATCH 03/18] Change `log_domains.children` database column's type to `jsonb` --- ...190404140234_change_log_domains_children_type_to_jsonb.rb | 5 +++++ db/structure.sql | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb diff --git a/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb b/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb new file mode 100644 index 000000000..b511d7293 --- /dev/null +++ b/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb @@ -0,0 +1,5 @@ +class ChangeLogDomainsChildrenTypeToJsonb < ActiveRecord::Migration + def change + change_column :log_domains, :children, 'jsonb USING children::jsonb' + end +end \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index d1f379a74..0a1a8203f 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1466,7 +1466,7 @@ CREATE TABLE public.log_domains ( object_changes json, created_at timestamp without time zone, session character varying, - children json, + children jsonb, uuid character varying ); @@ -4792,6 +4792,8 @@ INSERT INTO schema_migrations (version) VALUES ('20190328151516'); INSERT INTO schema_migrations (version) VALUES ('20190328151838'); +INSERT INTO schema_migrations (version) VALUES ('20190404140234'); + INSERT INTO schema_migrations (version) VALUES ('20190415120246'); INSERT INTO schema_migrations (version) VALUES ('20190426174225'); From de8e663d13943123a9fe61953dd5ab29c7cbe75a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 4 Apr 2019 18:21:08 +0300 Subject: [PATCH 04/18] Change `log_domains.children` database column's type to `jsonb` --- ...ange_log_domains_children_type_to_jsonb.rb | 5 + db/structure.sql | 410 +++++++++--------- 2 files changed, 211 insertions(+), 204 deletions(-) create mode 100644 db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb diff --git a/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb b/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb new file mode 100644 index 000000000..b511d7293 --- /dev/null +++ b/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb @@ -0,0 +1,5 @@ +class ChangeLogDomainsChildrenTypeToJsonb < ActiveRecord::Migration + def change + change_column :log_domains, :children, 'jsonb USING children::jsonb' + end +end \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index d1f379a74..d8dcacf5d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -295,7 +295,7 @@ SET default_tablespace = ''; SET default_with_oids = false; -- --- Name: account_activities; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: account_activities; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.account_activities ( @@ -335,7 +335,7 @@ ALTER SEQUENCE public.account_activities_id_seq OWNED BY public.account_activiti -- --- Name: accounts; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: accounts; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.accounts ( @@ -371,7 +371,7 @@ ALTER SEQUENCE public.accounts_id_seq OWNED BY public.accounts.id; -- --- Name: actions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: actions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.actions ( @@ -403,7 +403,7 @@ ALTER SEQUENCE public.actions_id_seq OWNED BY public.actions.id; -- --- Name: auctions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: auctions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.auctions ( @@ -436,7 +436,7 @@ ALTER SEQUENCE public.auctions_id_seq OWNED BY public.auctions.id; -- --- Name: bank_statements; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: bank_statements; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.bank_statements ( @@ -472,7 +472,7 @@ ALTER SEQUENCE public.bank_statements_id_seq OWNED BY public.bank_statements.id; -- --- Name: bank_transactions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: bank_transactions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.bank_transactions ( @@ -517,7 +517,7 @@ ALTER SEQUENCE public.bank_transactions_id_seq OWNED BY public.bank_transactions -- --- Name: blocked_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: blocked_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.blocked_domains ( @@ -550,7 +550,7 @@ ALTER SEQUENCE public.blocked_domains_id_seq OWNED BY public.blocked_domains.id; -- --- Name: certificates; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: certificates; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.certificates ( @@ -588,7 +588,7 @@ ALTER SEQUENCE public.certificates_id_seq OWNED BY public.certificates.id; -- --- Name: contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.contacts ( @@ -646,7 +646,7 @@ ALTER SEQUENCE public.contacts_id_seq OWNED BY public.contacts.id; -- --- Name: directos; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: directos; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.directos ( @@ -681,7 +681,7 @@ ALTER SEQUENCE public.directos_id_seq OWNED BY public.directos.id; -- --- Name: dnskeys; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: dnskeys; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.dnskeys ( @@ -722,7 +722,7 @@ ALTER SEQUENCE public.dnskeys_id_seq OWNED BY public.dnskeys.id; -- --- Name: domain_contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: domain_contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.domain_contacts ( @@ -760,7 +760,7 @@ ALTER SEQUENCE public.domain_contacts_id_seq OWNED BY public.domain_contacts.id; -- --- Name: domain_transfers; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: domain_transfers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.domain_transfers ( @@ -797,7 +797,7 @@ ALTER SEQUENCE public.domain_transfers_id_seq OWNED BY public.domain_transfers.i -- --- Name: domains; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.domains ( @@ -855,7 +855,7 @@ ALTER SEQUENCE public.domains_id_seq OWNED BY public.domains.id; -- --- Name: epp_sessions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: epp_sessions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.epp_sessions ( @@ -887,7 +887,7 @@ ALTER SEQUENCE public.epp_sessions_id_seq OWNED BY public.epp_sessions.id; -- --- Name: invoice_items; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: invoice_items; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.invoice_items ( @@ -924,7 +924,7 @@ ALTER SEQUENCE public.invoice_items_id_seq OWNED BY public.invoice_items.id; -- --- Name: invoices; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: invoices; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.invoices ( @@ -994,7 +994,7 @@ ALTER SEQUENCE public.invoices_id_seq OWNED BY public.invoices.id; -- --- Name: keyrelays; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: keyrelays; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.keyrelays ( @@ -1037,7 +1037,7 @@ ALTER SEQUENCE public.keyrelays_id_seq OWNED BY public.keyrelays.id; -- --- Name: legal_documents; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: legal_documents; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.legal_documents ( @@ -1072,7 +1072,7 @@ ALTER SEQUENCE public.legal_documents_id_seq OWNED BY public.legal_documents.id; -- --- Name: log_account_activities; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_account_activities; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_account_activities ( @@ -1110,7 +1110,7 @@ ALTER SEQUENCE public.log_account_activities_id_seq OWNED BY public.log_account_ -- --- Name: log_accounts; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_accounts; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_accounts ( @@ -1148,7 +1148,7 @@ ALTER SEQUENCE public.log_accounts_id_seq OWNED BY public.log_accounts.id; -- --- Name: log_actions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_actions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_actions ( @@ -1186,7 +1186,7 @@ ALTER SEQUENCE public.log_actions_id_seq OWNED BY public.log_actions.id; -- --- Name: log_bank_statements; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_bank_statements; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_bank_statements ( @@ -1224,7 +1224,7 @@ ALTER SEQUENCE public.log_bank_statements_id_seq OWNED BY public.log_bank_statem -- --- Name: log_bank_transactions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_bank_transactions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_bank_transactions ( @@ -1262,7 +1262,7 @@ ALTER SEQUENCE public.log_bank_transactions_id_seq OWNED BY public.log_bank_tran -- --- Name: log_blocked_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_blocked_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_blocked_domains ( @@ -1300,7 +1300,7 @@ ALTER SEQUENCE public.log_blocked_domains_id_seq OWNED BY public.log_blocked_dom -- --- Name: log_certificates; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_certificates; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_certificates ( @@ -1338,7 +1338,7 @@ ALTER SEQUENCE public.log_certificates_id_seq OWNED BY public.log_certificates.i -- --- Name: log_contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_contacts ( @@ -1377,7 +1377,7 @@ ALTER SEQUENCE public.log_contacts_id_seq OWNED BY public.log_contacts.id; -- --- Name: log_dnskeys; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_dnskeys; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_dnskeys ( @@ -1415,7 +1415,7 @@ ALTER SEQUENCE public.log_dnskeys_id_seq OWNED BY public.log_dnskeys.id; -- --- Name: log_domain_contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_domain_contacts; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_domain_contacts ( @@ -1453,7 +1453,7 @@ ALTER SEQUENCE public.log_domain_contacts_id_seq OWNED BY public.log_domain_cont -- --- Name: log_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_domains ( @@ -1466,7 +1466,7 @@ CREATE TABLE public.log_domains ( object_changes json, created_at timestamp without time zone, session character varying, - children json, + children jsonb, uuid character varying ); @@ -1491,7 +1491,7 @@ ALTER SEQUENCE public.log_domains_id_seq OWNED BY public.log_domains.id; -- --- Name: log_invoice_items; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_invoice_items; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_invoice_items ( @@ -1529,7 +1529,7 @@ ALTER SEQUENCE public.log_invoice_items_id_seq OWNED BY public.log_invoice_items -- --- Name: log_invoices; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_invoices; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_invoices ( @@ -1567,7 +1567,7 @@ ALTER SEQUENCE public.log_invoices_id_seq OWNED BY public.log_invoices.id; -- --- Name: log_keyrelays; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_keyrelays; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_keyrelays ( @@ -1605,7 +1605,7 @@ ALTER SEQUENCE public.log_keyrelays_id_seq OWNED BY public.log_keyrelays.id; -- --- Name: log_nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_nameservers ( @@ -1643,7 +1643,7 @@ ALTER SEQUENCE public.log_nameservers_id_seq OWNED BY public.log_nameservers.id; -- --- Name: log_notifications; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_notifications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_notifications ( @@ -1681,7 +1681,7 @@ ALTER SEQUENCE public.log_notifications_id_seq OWNED BY public.log_notifications -- --- Name: log_registrars; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_registrars; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_registrars ( @@ -1719,7 +1719,7 @@ ALTER SEQUENCE public.log_registrars_id_seq OWNED BY public.log_registrars.id; -- --- Name: log_reserved_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_reserved_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_reserved_domains ( @@ -1757,7 +1757,7 @@ ALTER SEQUENCE public.log_reserved_domains_id_seq OWNED BY public.log_reserved_d -- --- Name: log_settings; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_settings; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_settings ( @@ -1795,7 +1795,7 @@ ALTER SEQUENCE public.log_settings_id_seq OWNED BY public.log_settings.id; -- --- Name: log_users; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_users ( @@ -1833,7 +1833,7 @@ ALTER SEQUENCE public.log_users_id_seq OWNED BY public.log_users.id; -- --- Name: log_white_ips; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: log_white_ips; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.log_white_ips ( @@ -1871,7 +1871,7 @@ ALTER SEQUENCE public.log_white_ips_id_seq OWNED BY public.log_white_ips.id; -- --- Name: nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.nameservers ( @@ -1909,7 +1909,7 @@ ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id; -- --- Name: notifications; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: notifications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.notifications ( @@ -1947,7 +1947,7 @@ ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id; -- --- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.prices ( @@ -1985,7 +1985,7 @@ ALTER SEQUENCE public.prices_id_seq OWNED BY public.prices.id; -- --- Name: que_jobs; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: que_jobs; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.que_jobs ( @@ -2027,7 +2027,7 @@ ALTER SEQUENCE public.que_jobs_job_id_seq OWNED BY public.que_jobs.job_id; -- --- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.registrant_verifications ( @@ -2062,7 +2062,7 @@ ALTER SEQUENCE public.registrant_verifications_id_seq OWNED BY public.registrant -- --- Name: registrars; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: registrars; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.registrars ( @@ -2115,7 +2115,7 @@ ALTER SEQUENCE public.registrars_id_seq OWNED BY public.registrars.id; -- --- Name: reserved_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: reserved_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.reserved_domains ( @@ -2150,7 +2150,7 @@ ALTER SEQUENCE public.reserved_domains_id_seq OWNED BY public.reserved_domains.i -- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.schema_migrations ( @@ -2159,7 +2159,7 @@ CREATE TABLE public.schema_migrations ( -- --- Name: settings; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: settings; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.settings ( @@ -2195,7 +2195,7 @@ ALTER SEQUENCE public.settings_id_seq OWNED BY public.settings.id; -- --- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.users ( @@ -2249,7 +2249,7 @@ ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; -- --- Name: versions; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: versions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.versions ( @@ -2284,7 +2284,7 @@ ALTER SEQUENCE public.versions_id_seq OWNED BY public.versions.id; -- --- Name: white_ips; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: white_ips; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.white_ips ( @@ -2320,7 +2320,7 @@ ALTER SEQUENCE public.white_ips_id_seq OWNED BY public.white_ips.id; -- --- Name: whois_records; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: whois_records; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.whois_records ( @@ -2355,7 +2355,7 @@ ALTER SEQUENCE public.whois_records_id_seq OWNED BY public.whois_records.id; -- --- Name: zones; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: zones; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.zones ( @@ -2769,7 +2769,7 @@ ALTER TABLE ONLY public.zones ALTER COLUMN id SET DEFAULT nextval('public.zones_ -- --- Name: account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.account_activities @@ -2777,7 +2777,7 @@ ALTER TABLE ONLY public.account_activities -- --- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.accounts @@ -2785,7 +2785,7 @@ ALTER TABLE ONLY public.accounts -- --- Name: actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.actions @@ -2793,7 +2793,7 @@ ALTER TABLE ONLY public.actions -- --- Name: auctions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: auctions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.auctions @@ -2801,7 +2801,7 @@ ALTER TABLE ONLY public.auctions -- --- Name: bank_statements_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: bank_statements_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.bank_statements @@ -2809,7 +2809,7 @@ ALTER TABLE ONLY public.bank_statements -- --- Name: bank_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: bank_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.bank_transactions @@ -2817,7 +2817,7 @@ ALTER TABLE ONLY public.bank_transactions -- --- Name: blocked_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: blocked_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.blocked_domains @@ -2825,7 +2825,7 @@ ALTER TABLE ONLY public.blocked_domains -- --- Name: certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.certificates @@ -2833,7 +2833,7 @@ ALTER TABLE ONLY public.certificates -- --- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.contacts @@ -2841,7 +2841,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: directos_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: directos_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.directos @@ -2849,7 +2849,7 @@ ALTER TABLE ONLY public.directos -- --- Name: dnskeys_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: dnskeys_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.dnskeys @@ -2857,7 +2857,7 @@ ALTER TABLE ONLY public.dnskeys -- --- Name: domain_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: domain_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.domain_contacts @@ -2865,7 +2865,7 @@ ALTER TABLE ONLY public.domain_contacts -- --- Name: domain_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: domain_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.domain_transfers @@ -2873,7 +2873,7 @@ ALTER TABLE ONLY public.domain_transfers -- --- Name: domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.domains @@ -2881,7 +2881,7 @@ ALTER TABLE ONLY public.domains -- --- Name: epp_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: epp_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.epp_sessions @@ -2889,7 +2889,7 @@ ALTER TABLE ONLY public.epp_sessions -- --- Name: invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.invoice_items @@ -2897,7 +2897,7 @@ ALTER TABLE ONLY public.invoice_items -- --- Name: invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.invoices @@ -2905,7 +2905,7 @@ ALTER TABLE ONLY public.invoices -- --- Name: keyrelays_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: keyrelays_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.keyrelays @@ -2913,7 +2913,7 @@ ALTER TABLE ONLY public.keyrelays -- --- Name: legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.legal_documents @@ -2921,7 +2921,7 @@ ALTER TABLE ONLY public.legal_documents -- --- Name: log_account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_account_activities @@ -2929,7 +2929,7 @@ ALTER TABLE ONLY public.log_account_activities -- --- Name: log_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_accounts @@ -2937,7 +2937,7 @@ ALTER TABLE ONLY public.log_accounts -- --- Name: log_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_actions @@ -2945,7 +2945,7 @@ ALTER TABLE ONLY public.log_actions -- --- Name: log_bank_statements_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_bank_statements_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_bank_statements @@ -2953,7 +2953,7 @@ ALTER TABLE ONLY public.log_bank_statements -- --- Name: log_bank_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_bank_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_bank_transactions @@ -2961,7 +2961,7 @@ ALTER TABLE ONLY public.log_bank_transactions -- --- Name: log_blocked_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_blocked_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_blocked_domains @@ -2969,7 +2969,7 @@ ALTER TABLE ONLY public.log_blocked_domains -- --- Name: log_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_certificates @@ -2977,7 +2977,7 @@ ALTER TABLE ONLY public.log_certificates -- --- Name: log_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_contacts @@ -2985,7 +2985,7 @@ ALTER TABLE ONLY public.log_contacts -- --- Name: log_dnskeys_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_dnskeys_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_dnskeys @@ -2993,7 +2993,7 @@ ALTER TABLE ONLY public.log_dnskeys -- --- Name: log_domain_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_domain_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_domain_contacts @@ -3001,7 +3001,7 @@ ALTER TABLE ONLY public.log_domain_contacts -- --- Name: log_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_domains @@ -3009,7 +3009,7 @@ ALTER TABLE ONLY public.log_domains -- --- Name: log_invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_invoice_items @@ -3017,7 +3017,7 @@ ALTER TABLE ONLY public.log_invoice_items -- --- Name: log_invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_invoices @@ -3025,7 +3025,7 @@ ALTER TABLE ONLY public.log_invoices -- --- Name: log_keyrelays_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_keyrelays_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_keyrelays @@ -3033,7 +3033,7 @@ ALTER TABLE ONLY public.log_keyrelays -- --- Name: log_nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_nameservers @@ -3041,7 +3041,7 @@ ALTER TABLE ONLY public.log_nameservers -- --- Name: log_notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_notifications @@ -3049,7 +3049,7 @@ ALTER TABLE ONLY public.log_notifications -- --- Name: log_registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_registrars @@ -3057,7 +3057,7 @@ ALTER TABLE ONLY public.log_registrars -- --- Name: log_reserved_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_reserved_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_reserved_domains @@ -3065,7 +3065,7 @@ ALTER TABLE ONLY public.log_reserved_domains -- --- Name: log_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_settings @@ -3073,7 +3073,7 @@ ALTER TABLE ONLY public.log_settings -- --- Name: log_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_users @@ -3081,7 +3081,7 @@ ALTER TABLE ONLY public.log_users -- --- Name: log_white_ips_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: log_white_ips_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.log_white_ips @@ -3089,7 +3089,7 @@ ALTER TABLE ONLY public.log_white_ips -- --- Name: nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.nameservers @@ -3097,7 +3097,7 @@ ALTER TABLE ONLY public.nameservers -- --- Name: notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.notifications @@ -3105,7 +3105,7 @@ ALTER TABLE ONLY public.notifications -- --- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.prices @@ -3113,7 +3113,7 @@ ALTER TABLE ONLY public.prices -- --- Name: que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.que_jobs @@ -3121,7 +3121,7 @@ ALTER TABLE ONLY public.que_jobs -- --- Name: registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.registrant_verifications @@ -3129,7 +3129,7 @@ ALTER TABLE ONLY public.registrant_verifications -- --- Name: registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.registrars @@ -3137,7 +3137,7 @@ ALTER TABLE ONLY public.registrars -- --- Name: reserved_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: reserved_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.reserved_domains @@ -3145,7 +3145,7 @@ ALTER TABLE ONLY public.reserved_domains -- --- Name: settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.settings @@ -3153,7 +3153,7 @@ ALTER TABLE ONLY public.settings -- --- Name: uniq_contact_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: uniq_contact_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.contacts @@ -3161,7 +3161,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: uniq_domain_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: uniq_domain_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.domains @@ -3169,7 +3169,7 @@ ALTER TABLE ONLY public.domains -- --- Name: uniq_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: uniq_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.auctions @@ -3177,7 +3177,7 @@ ALTER TABLE ONLY public.auctions -- --- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.registrars @@ -3185,7 +3185,7 @@ ALTER TABLE ONLY public.registrars -- --- Name: unique_contact_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_contact_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.contacts @@ -3193,7 +3193,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: unique_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.registrars @@ -3201,7 +3201,7 @@ ALTER TABLE ONLY public.registrars -- --- Name: unique_reference_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_reference_no; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.registrars @@ -3209,7 +3209,7 @@ ALTER TABLE ONLY public.registrars -- --- Name: unique_registration_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_registration_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.auctions @@ -3217,7 +3217,7 @@ ALTER TABLE ONLY public.auctions -- --- Name: unique_session_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_session_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.epp_sessions @@ -3225,7 +3225,7 @@ ALTER TABLE ONLY public.epp_sessions -- --- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.zones @@ -3233,7 +3233,7 @@ ALTER TABLE ONLY public.zones -- --- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.users @@ -3241,7 +3241,7 @@ ALTER TABLE ONLY public.users -- --- Name: versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.versions @@ -3249,7 +3249,7 @@ ALTER TABLE ONLY public.versions -- --- Name: white_ips_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: white_ips_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.white_ips @@ -3257,7 +3257,7 @@ ALTER TABLE ONLY public.white_ips -- --- Name: whois_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: whois_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.whois_records @@ -3265,7 +3265,7 @@ ALTER TABLE ONLY public.whois_records -- --- Name: zones_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: zones_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.zones @@ -3273,602 +3273,602 @@ ALTER TABLE ONLY public.zones -- --- Name: index_account_activities_on_account_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_account_activities_on_account_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_account_activities_on_account_id ON public.account_activities USING btree (account_id); -- --- Name: index_account_activities_on_bank_transaction_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_account_activities_on_bank_transaction_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_account_activities_on_bank_transaction_id ON public.account_activities USING btree (bank_transaction_id); -- --- Name: index_account_activities_on_invoice_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_account_activities_on_invoice_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_account_activities_on_invoice_id ON public.account_activities USING btree (invoice_id); -- --- Name: index_accounts_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_accounts_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_accounts_on_registrar_id ON public.accounts USING btree (registrar_id); -- --- Name: index_blocked_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_blocked_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_blocked_domains_on_name ON public.blocked_domains USING btree (name); -- --- Name: index_certificates_on_api_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_certificates_on_api_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_certificates_on_api_user_id ON public.certificates USING btree (api_user_id); -- --- Name: index_contacts_on_code; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_contacts_on_code; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_contacts_on_code ON public.contacts USING btree (code); -- --- Name: index_contacts_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_contacts_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_contacts_on_registrar_id ON public.contacts USING btree (registrar_id); -- --- Name: index_contacts_on_registrar_id_and_ident_type; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_contacts_on_registrar_id_and_ident_type; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_contacts_on_registrar_id_and_ident_type ON public.contacts USING btree (registrar_id, ident_type); -- --- Name: index_directos_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_directos_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_directos_on_item_type_and_item_id ON public.directos USING btree (item_type, item_id); -- --- Name: index_dnskeys_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_dnskeys_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_dnskeys_on_domain_id ON public.dnskeys USING btree (domain_id); -- --- Name: index_dnskeys_on_legacy_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_dnskeys_on_legacy_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_dnskeys_on_legacy_domain_id ON public.dnskeys USING btree (legacy_domain_id); -- --- Name: index_domain_contacts_on_contact_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domain_contacts_on_contact_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domain_contacts_on_contact_id ON public.domain_contacts USING btree (contact_id); -- --- Name: index_domain_contacts_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domain_contacts_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domain_contacts_on_domain_id ON public.domain_contacts USING btree (domain_id); -- --- Name: index_domain_transfers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domain_transfers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domain_transfers_on_domain_id ON public.domain_transfers USING btree (domain_id); -- --- Name: index_domains_on_delete_date; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_delete_date; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_delete_date ON public.domains USING btree (delete_date); -- --- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_domains_on_name ON public.domains USING btree (name); -- --- Name: index_domains_on_outzone_at; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_outzone_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_outzone_at ON public.domains USING btree (outzone_at); -- --- Name: index_domains_on_registrant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_registrant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_registrant_id ON public.domains USING btree (registrant_id); -- --- Name: index_domains_on_registrant_verification_asked_at; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_registrant_verification_asked_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_registrant_verification_asked_at ON public.domains USING btree (registrant_verification_asked_at); -- --- Name: index_domains_on_registrant_verification_token; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_registrant_verification_token; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_registrant_verification_token ON public.domains USING btree (registrant_verification_token); -- --- Name: index_domains_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_registrar_id ON public.domains USING btree (registrar_id); -- --- Name: index_domains_on_statuses; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_domains_on_statuses; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_statuses ON public.domains USING gin (statuses); -- --- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_epp_sessions_on_updated_at ON public.epp_sessions USING btree (updated_at); -- --- Name: index_invoice_items_on_invoice_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_invoice_items_on_invoice_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_invoice_items_on_invoice_id ON public.invoice_items USING btree (invoice_id); -- --- Name: index_invoices_on_buyer_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_invoices_on_buyer_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_invoices_on_buyer_id ON public.invoices USING btree (buyer_id); -- --- Name: index_invoices_on_seller_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_invoices_on_seller_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_invoices_on_seller_id ON public.invoices USING btree (seller_id); -- --- Name: index_keyrelays_on_accepter_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_keyrelays_on_accepter_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_keyrelays_on_accepter_id ON public.keyrelays USING btree (accepter_id); -- --- Name: index_keyrelays_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_keyrelays_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_keyrelays_on_domain_id ON public.keyrelays USING btree (domain_id); -- --- Name: index_keyrelays_on_requester_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_keyrelays_on_requester_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_keyrelays_on_requester_id ON public.keyrelays USING btree (requester_id); -- --- Name: index_legal_documents_on_checksum; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_legal_documents_on_checksum; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_legal_documents_on_checksum ON public.legal_documents USING btree (checksum); -- --- Name: index_legal_documents_on_documentable_type_and_documentable_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_legal_documents_on_documentable_type_and_documentable_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_legal_documents_on_documentable_type_and_documentable_id ON public.legal_documents USING btree (documentable_type, documentable_id); -- --- Name: index_log_account_activities_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_account_activities_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_account_activities_on_item_type_and_item_id ON public.log_account_activities USING btree (item_type, item_id); -- --- Name: index_log_account_activities_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_account_activities_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_account_activities_on_whodunnit ON public.log_account_activities USING btree (whodunnit); -- --- Name: index_log_accounts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_accounts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_accounts_on_item_type_and_item_id ON public.log_accounts USING btree (item_type, item_id); -- --- Name: index_log_accounts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_accounts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_accounts_on_whodunnit ON public.log_accounts USING btree (whodunnit); -- --- Name: index_log_bank_statements_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_bank_statements_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_statements_on_item_type_and_item_id ON public.log_bank_statements USING btree (item_type, item_id); -- --- Name: index_log_bank_statements_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_bank_statements_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_statements_on_whodunnit ON public.log_bank_statements USING btree (whodunnit); -- --- Name: index_log_bank_transactions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_bank_transactions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_transactions_on_item_type_and_item_id ON public.log_bank_transactions USING btree (item_type, item_id); -- --- Name: index_log_bank_transactions_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_bank_transactions_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_transactions_on_whodunnit ON public.log_bank_transactions USING btree (whodunnit); -- --- Name: index_log_blocked_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_blocked_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_blocked_domains_on_item_type_and_item_id ON public.log_blocked_domains USING btree (item_type, item_id); -- --- Name: index_log_blocked_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_blocked_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_blocked_domains_on_whodunnit ON public.log_blocked_domains USING btree (whodunnit); -- --- Name: index_log_certificates_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_certificates_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_certificates_on_item_type_and_item_id ON public.log_certificates USING btree (item_type, item_id); -- --- Name: index_log_certificates_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_certificates_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_certificates_on_whodunnit ON public.log_certificates USING btree (whodunnit); -- --- Name: index_log_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_contacts_on_item_type_and_item_id ON public.log_contacts USING btree (item_type, item_id); -- --- Name: index_log_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_contacts_on_whodunnit ON public.log_contacts USING btree (whodunnit); -- --- Name: index_log_dnskeys_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_dnskeys_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_dnskeys_on_item_type_and_item_id ON public.log_dnskeys USING btree (item_type, item_id); -- --- Name: index_log_dnskeys_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_dnskeys_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_dnskeys_on_whodunnit ON public.log_dnskeys USING btree (whodunnit); -- --- Name: index_log_domain_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_domain_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domain_contacts_on_item_type_and_item_id ON public.log_domain_contacts USING btree (item_type, item_id); -- --- Name: index_log_domain_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_domain_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domain_contacts_on_whodunnit ON public.log_domain_contacts USING btree (whodunnit); -- --- Name: index_log_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domains_on_item_type_and_item_id ON public.log_domains USING btree (item_type, item_id); -- --- Name: index_log_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domains_on_whodunnit ON public.log_domains USING btree (whodunnit); -- --- Name: index_log_invoice_items_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_invoice_items_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoice_items_on_item_type_and_item_id ON public.log_invoice_items USING btree (item_type, item_id); -- --- Name: index_log_invoice_items_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_invoice_items_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoice_items_on_whodunnit ON public.log_invoice_items USING btree (whodunnit); -- --- Name: index_log_invoices_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_invoices_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoices_on_item_type_and_item_id ON public.log_invoices USING btree (item_type, item_id); -- --- Name: index_log_invoices_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_invoices_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoices_on_whodunnit ON public.log_invoices USING btree (whodunnit); -- --- Name: index_log_keyrelays_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_keyrelays_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON public.log_keyrelays USING btree (item_type, item_id); -- --- Name: index_log_keyrelays_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_keyrelays_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_keyrelays_on_whodunnit ON public.log_keyrelays USING btree (whodunnit); -- --- Name: index_log_nameservers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_nameservers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_nameservers_on_item_type_and_item_id ON public.log_nameservers USING btree (item_type, item_id); -- --- Name: index_log_nameservers_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_nameservers_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_nameservers_on_whodunnit ON public.log_nameservers USING btree (whodunnit); -- --- Name: index_log_notifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_notifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_notifications_on_item_type_and_item_id ON public.log_notifications USING btree (item_type, item_id); -- --- Name: index_log_notifications_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_notifications_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_notifications_on_whodunnit ON public.log_notifications USING btree (whodunnit); -- --- Name: index_log_registrars_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_registrars_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_registrars_on_item_type_and_item_id ON public.log_registrars USING btree (item_type, item_id); -- --- Name: index_log_registrars_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_registrars_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_registrars_on_whodunnit ON public.log_registrars USING btree (whodunnit); -- --- Name: index_log_reserved_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_reserved_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_reserved_domains_on_item_type_and_item_id ON public.log_reserved_domains USING btree (item_type, item_id); -- --- Name: index_log_reserved_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_reserved_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_reserved_domains_on_whodunnit ON public.log_reserved_domains USING btree (whodunnit); -- --- Name: index_log_settings_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_settings_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_settings_on_item_type_and_item_id ON public.log_settings USING btree (item_type, item_id); -- --- Name: index_log_settings_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_settings_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_settings_on_whodunnit ON public.log_settings USING btree (whodunnit); -- --- Name: index_log_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_users_on_item_type_and_item_id ON public.log_users USING btree (item_type, item_id); -- --- Name: index_log_users_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_log_users_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_users_on_whodunnit ON public.log_users USING btree (whodunnit); -- --- Name: index_nameservers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_nameservers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_nameservers_on_domain_id ON public.nameservers USING btree (domain_id); -- --- Name: index_notifications_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_notifications_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING btree (registrar_id); -- --- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_prices_on_zone_id ON public.prices USING btree (zone_id); -- --- Name: index_registrant_verifications_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_registrant_verifications_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_registrant_verifications_on_created_at ON public.registrant_verifications USING btree (created_at); -- --- Name: index_registrant_verifications_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_registrant_verifications_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_registrant_verifications_on_domain_id ON public.registrant_verifications USING btree (domain_id); -- --- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_settings_on_thing_type_and_thing_id_and_var ON public.settings USING btree (thing_type, thing_id, var); -- --- Name: index_users_on_identity_code; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_users_on_identity_code; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_users_on_identity_code ON public.users USING btree (identity_code); -- --- Name: index_users_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_users_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_id); -- --- Name: index_versions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_versions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_versions_on_item_type_and_item_id ON public.versions USING btree (item_type, item_id); -- --- Name: index_whois_records_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_whois_records_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_whois_records_on_domain_id ON public.whois_records USING btree (domain_id); -- --- Name: index_whois_records_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_whois_records_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_whois_records_on_registrar_id ON public.whois_records USING btree (registrar_id); -- --- Name: log_contacts_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: log_contacts_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_contacts_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_id'::text))::integer)); -- --- Name: log_dnskeys_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: log_dnskeys_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_dnskeys_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_domain_id'::text))::integer)); -- --- Name: log_domains_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: log_domains_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_domains_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_id'::text))::integer)); -- --- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_nameservers_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_domain_id'::text))::integer)); -- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version); @@ -4792,6 +4792,8 @@ INSERT INTO schema_migrations (version) VALUES ('20190328151516'); INSERT INTO schema_migrations (version) VALUES ('20190328151838'); +INSERT INTO schema_migrations (version) VALUES ('20190404140234'); + INSERT INTO schema_migrations (version) VALUES ('20190415120246'); INSERT INTO schema_migrations (version) VALUES ('20190426174225'); From 3c7756680dfe5ac6356121645000a1bc0f7316a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Wed, 2 Sep 2020 16:31:26 +0300 Subject: [PATCH 05/18] Resolve some minor CC issues --- app/models/concerns/contact/archivable.rb | 3 ++- app/models/contact.rb | 2 -- app/models/inactive_contacts.rb | 2 +- ...190404140234_change_log_domains_children_type_to_jsonb.rb | 5 ----- db/structure.sql | 3 ++- lib/tasks/contacts/archive.rake | 2 +- test/models/contact/archivable_test.rb | 4 ++-- test/models/contact_test.rb | 1 + test/tasks/contacts/archive_test.rb | 4 ++-- 9 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index c2a8ca103..36146d5b0 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -20,6 +20,7 @@ module Concerns def archive raise 'Contact cannot be archived' unless archivable? + destroy! end @@ -35,4 +36,4 @@ module Concerns end end end -end \ No newline at end of file +end diff --git a/app/models/contact.rb b/app/models/contact.rb index 7e9aa75c0..03aa902b8 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -240,8 +240,6 @@ class Contact < ApplicationRecord contacts.id)') end - private - def registrant_user_company_contacts(registrant_user) ident = registrant_user.companies.collect(&:registration_number) diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb index a1ccda205..a4123c8de 100644 --- a/app/models/inactive_contacts.rb +++ b/app/models/inactive_contacts.rb @@ -11,4 +11,4 @@ class InactiveContacts yield contact if block_given? end end -end \ No newline at end of file +end diff --git a/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb b/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb deleted file mode 100644 index b511d7293..000000000 --- a/db/migrate/20190404140234_change_log_domains_children_type_to_jsonb.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeLogDomainsChildrenTypeToJsonb < ActiveRecord::Migration - def change - change_column :log_domains, :children, 'jsonb USING children::jsonb' - end -end \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index d0c941cb5..806e1a49d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4848,4 +4848,5 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200807110611'), ('20200811074839'), ('20200812090409'), -('20200812125810'); +('20200812125810'), +('20200902131603'); diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index 1778be98b..80ace6ce0 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -11,4 +11,4 @@ namespace :contacts do puts "Archived total: #{archived_contacts.count}" end -end \ No newline at end of file +end diff --git a/test/models/contact/archivable_test.rb b/test/models/contact/archivable_test.rb index ebd3b2d12..9b2c75f0b 100644 --- a/test/models/contact/archivable_test.rb +++ b/test/models/contact/archivable_test.rb @@ -67,7 +67,7 @@ class ArchivableContactTest < ActiveSupport::TestCase other_contact = contacts(:william) assert_not_equal other_contact, contact - Domain.update_all(registrant_id: other_contact) + Domain.update_all(registrant_id: other_contact.id) DomainContact.delete_all @@ -78,4 +78,4 @@ class ArchivableContactTest < ActiveSupport::TestCase Contact.inactivity_period = 99.years @contact end -end \ No newline at end of file +end diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index bbbafc511..1083a54f3 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -267,6 +267,7 @@ class ContactTest < ActiveSupport::TestCase contact = unlinked_contact domains(:shop).update_columns(registrant_id: contact.becomes(Registrant)) + reload assert Contact.unlinked.exclude?(contact), 'Contact should be excluded' end diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb index 54e7a6650..cd137a8c4 100644 --- a/test/tasks/contacts/archive_test.rb +++ b/test/tasks/contacts/archive_test.rb @@ -27,7 +27,7 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase other_contact = contacts(:william) assert_not_equal other_contact, contact - Domain.update_all(registrant_id: other_contact) + Domain.update_all(registrant_id: other_contact.id) DomainContact.delete_all @@ -43,4 +43,4 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase def run_task Rake::Task['contacts:archive'].execute end -end \ No newline at end of file +end From 7a24eab63a6ee684526a5140c505c0cf2dba6f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 10:46:05 +0300 Subject: [PATCH 06/18] Fix contact archivation tests --- test/models/contact_test.rb | 3 +-- test/tasks/contacts/archive_test.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index 1083a54f3..942b71b06 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -265,9 +265,8 @@ class ContactTest < ActiveSupport::TestCase def test_unlinked_scope_skips_contact_that_is_linked_as_registrant contact = unlinked_contact - domains(:shop).update_columns(registrant_id: contact.becomes(Registrant)) + domains(:shop).update_columns(registrant_id: contact.becomes(Registrant).id) - reload assert Contact.unlinked.exclude?(contact), 'Contact should be excluded' end diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb index cd137a8c4..a22110ae3 100644 --- a/test/tasks/contacts/archive_test.rb +++ b/test/tasks/contacts/archive_test.rb @@ -36,7 +36,7 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase def eliminate_effect_of_all_contacts_except(contact) Contact.connection.disable_referential_integrity do - Contact.delete_all("id != #{contact.id}") + Contact.where("id != #{contact.id}").delete_all end end From 821c52a8add6baf0db057b749e9478e130487b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 11:42:18 +0300 Subject: [PATCH 07/18] Submit only object ID to DomainVersion linked methods instead of full object --- app/models/concerns/contact/archivable.rb | 9 +++----- app/models/version/domain_version.rb | 18 ++++++++-------- test/models/version/domain_version_test.rb | 24 +++++++++++----------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 36146d5b0..1968ed9f1 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -27,12 +27,9 @@ module Concerns private def inactive? - if DomainVersion.was_contact_linked?(self) - DomainVersion.contact_unlinked_more_than?(contact: self, - period: inactivity_period) - else - created_at <= inactivity_period.ago - end + return (created_at <= inactivity_period.ago) unless DomainVersion.was_contact_linked?(id) + + DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) end end end diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb index c7a5618db..27753960a 100644 --- a/app/models/version/domain_version.rb +++ b/app/models/version/domain_version.rb @@ -6,24 +6,24 @@ class DomainVersion < PaperTrail::Version scope :deleted, -> { where(event: 'destroy') } - def self.was_contact_linked?(contact) + def self.was_contact_linked?(contact_id) sql = <<-SQL SELECT COUNT(*) FROM #{table_name} WHERE - (children->'registrant') @> '#{contact.id}' + (children->'registrant') @> '#{contact_id}' OR - (children->'admin_contacts') @> '#{contact.id}' + (children->'admin_contacts') @> '#{contact_id}' OR - (children->'tech_contacts') @> '#{contact.id}' + (children->'tech_contacts') @> '#{contact_id}' SQL count_by_sql(sql).nonzero? end - def self.contact_unlinked_more_than?(contact:, period:) + def self.contact_unlinked_more_than?(contact_id:, period:) sql = <<-SQL SELECT COUNT(*) @@ -32,14 +32,14 @@ class DomainVersion < PaperTrail::Version WHERE created_at < TIMESTAMP WITH TIME ZONE '#{period.ago}' AND ( - (children->'registrant') @> '#{contact.id}' + (children->'registrant') @> '#{contact_id}' OR - (children->'admin_contacts') @> '#{contact.id}' + (children->'admin_contacts') @> '#{contact_id}' OR - (children->'tech_contacts') @> '#{contact.id}' + (children->'tech_contacts') @> '#{contact_id}' ) SQL count_by_sql(sql).nonzero? end -end \ No newline at end of file +end diff --git a/test/models/version/domain_version_test.rb b/test/models/version/domain_version_test.rb index 801705432..719fcf3ba 100644 --- a/test/models/version/domain_version_test.rb +++ b/test/models/version/domain_version_test.rb @@ -11,7 +11,7 @@ class DomainVersionTest < ActiveSupport::TestCase tech_contacts: [], registrant: [@contact.id] }) - assert DomainVersion.was_contact_linked?(@contact) + assert DomainVersion.was_contact_linked?(@contact.id) end def test_was_contact_linked_returns_true_when_contact_was_used_as_admin_contact @@ -19,7 +19,7 @@ class DomainVersionTest < ActiveSupport::TestCase tech_contacts: [], registrant: [] }) - assert DomainVersion.was_contact_linked?(@contact) + assert DomainVersion.was_contact_linked?(@contact.id) end def test_was_contact_linked_returns_true_when_contact_was_used_as_tech_contact @@ -27,7 +27,7 @@ class DomainVersionTest < ActiveSupport::TestCase tech_contacts: [@contact.id], registrant: [] }) - assert DomainVersion.was_contact_linked?(@contact) + assert DomainVersion.was_contact_linked?(@contact.id) end def test_was_contact_linked_returns_false_when_contact_was_not_used @@ -35,7 +35,7 @@ class DomainVersionTest < ActiveSupport::TestCase tech_contacts: [], registrant: [] }) - assert_not DomainVersion.was_contact_linked?(@contact) + assert_not DomainVersion.was_contact_linked?(@contact.id) end def test_contact_unlinked_more_than_returns_true_when_contact_was_linked_as_registrant_more_than_given_period @@ -45,7 +45,7 @@ class DomainVersionTest < ActiveSupport::TestCase registrant: [@contact.id] }) travel_to Time.zone.parse('2010-07-05 00:00:01') - assert DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end def test_contact_unlinked_more_than_given_period_as_admin_contact @@ -55,7 +55,7 @@ class DomainVersionTest < ActiveSupport::TestCase registrant: [] }) travel_to Time.zone.parse('2010-07-05 00:00:01') - assert DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end def test_contact_unlinked_more_than_given_period_as_tech_contact @@ -65,7 +65,7 @@ class DomainVersionTest < ActiveSupport::TestCase registrant: [] }) travel_to Time.zone.parse('2010-07-05 00:00:01') - assert DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end def test_contact_linked_within_given_period_as_registrant @@ -75,7 +75,7 @@ class DomainVersionTest < ActiveSupport::TestCase registrant: [@contact.id] }) travel_to Time.zone.parse('2010-07-05') - assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end def test_contact_linked_within_given_period_as_admin_contact @@ -85,7 +85,7 @@ class DomainVersionTest < ActiveSupport::TestCase registrant: [] }) travel_to Time.zone.parse('2010-07-05') - assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end def test_contact_linked_within_given_period_as_tech_contact @@ -95,11 +95,11 @@ class DomainVersionTest < ActiveSupport::TestCase registrant: [] }) travel_to Time.zone.parse('2010-07-05') - assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end def test_contact_was_never_linked DomainVersion.delete_all - assert_not DomainVersion.contact_unlinked_more_than?(contact: @contact, period: 1.day) + assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day) end -end \ No newline at end of file +end From 6707ca17bfd8a26e9e08e4c3c9d6b10fdb095ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 12:22:59 +0300 Subject: [PATCH 08/18] Improve determining archivable contacts --- app/models/concerns/contact/archivable.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 1968ed9f1..185290339 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -27,9 +27,11 @@ module Concerns private def inactive? - return (created_at <= inactivity_period.ago) unless DomainVersion.was_contact_linked?(id) + if DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) + return true + end - DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) + DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago end end end From 28dea2f13c16280c8955e84f55f8f6c20139b8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 12:41:44 +0300 Subject: [PATCH 09/18] Reference orphans_contacts_in_months directly from Settings --- app/models/concerns/contact/archivable.rb | 9 ++++----- test/models/contact/archivable_test.rb | 8 ++++---- test/tasks/contacts/archive_test.rb | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 185290339..842efa775 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -3,11 +3,6 @@ module Concerns module Archivable extend ActiveSupport::Concern - included do - class_attribute :inactivity_period, instance_predicate: false, instance_writer: false - self.inactivity_period = Setting.orphans_contacts_in_months.months - end - class_methods do def archivable unlinked.find_each.select(&:archivable?) @@ -33,6 +28,10 @@ module Concerns DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago end + + def inactivity_period + Setting.orphans_contacts_in_months.months + end end end end diff --git a/test/models/contact/archivable_test.rb b/test/models/contact/archivable_test.rb index 9b2c75f0b..674feb505 100644 --- a/test/models/contact/archivable_test.rb +++ b/test/models/contact/archivable_test.rb @@ -14,7 +14,7 @@ class ArchivableContactTest < ActiveSupport::TestCase end def test_contact_is_archivable_when_it_was_never_linked_and_inactivity_period_has_passed - Contact.inactivity_period = 1.second + Setting.orphans_contacts_in_months = 0 @contact.created_at = Time.zone.parse('2010-07-05 00:00:00') travel_to Time.zone.parse('2010-07-05 00:00:01') @@ -24,7 +24,7 @@ class ArchivableContactTest < ActiveSupport::TestCase end def test_contact_is_not_archivable_when_it_was_never_linked_and_inactivity_period_has_not_passed - Contact.inactivity_period = 1.second + Setting.orphans_contacts_in_months = 5 @contact.created_at = Time.zone.parse('2010-07-05') travel_to Time.zone.parse('2010-07-05') @@ -62,7 +62,7 @@ class ArchivableContactTest < ActiveSupport::TestCase def archivable_contact contact = contacts(:john) - Contact.inactivity_period = 0.seconds + Setting.orphans_contacts_in_months = 0 DomainVersion.delete_all other_contact = contacts(:william) @@ -75,7 +75,7 @@ class ArchivableContactTest < ActiveSupport::TestCase end def unarchivable_contact - Contact.inactivity_period = 99.years + Setting.orphans_contacts_in_months = 1188 @contact end end diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb index a22110ae3..7120d2449 100644 --- a/test/tasks/contacts/archive_test.rb +++ b/test/tasks/contacts/archive_test.rb @@ -22,7 +22,7 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase def archivable_contact contact = contacts(:john) - Contact.inactivity_period = 0.seconds + Setting.orphans_contacts_in_months = 0 DomainVersion.delete_all other_contact = contacts(:william) From 816102130b133aabf891030b23fa5fb9661d5f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 15:59:59 +0300 Subject: [PATCH 10/18] Add logging to archiving process --- app/models/concerns/contact/archivable.rb | 15 ++++++++++++--- app/models/inactive_contacts.rb | 7 +++++++ lib/tasks/contacts/archive.rake | 5 +---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 842efa775..656e86a6a 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -9,12 +9,16 @@ module Concerns end end - def archivable? - inactive? + def archivable?(post: false) + inactive = inactive? + + log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post + + inactive end def archive - raise 'Contact cannot be archived' unless archivable? + raise 'Contact cannot be archived' unless archivable?(post: true) destroy! end @@ -32,6 +36,11 @@ module Concerns def inactivity_period Setting.orphans_contacts_in_months.months end + + def log(msg) + @logger ||= Logger.new(STDOUT) + @logger.info(msg) + end end end end diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb index a4123c8de..948b1f0bf 100644 --- a/app/models/inactive_contacts.rb +++ b/app/models/inactive_contacts.rb @@ -7,8 +7,15 @@ class InactiveContacts def archive contacts.each do |contact| + log("Archiving contact: id(#{contact.id}), code(#{contact.code})") + contact.archive yield contact if block_given? end end + + def log(msg) + @logger ||= Logger.new(STDOUT) + @logger.info(msg) + end end diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index 80ace6ce0..6ed29969f 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -2,13 +2,10 @@ namespace :contacts do desc 'Archives inactive contacts' task archive: :environment do + puts 'Starting to gather archivable contacts' inactive_contacts = InactiveContacts.new archived_contacts = inactive_contacts.archive - archived_contacts.each do |contact| - puts "Contact ##{contact.id} (code: #{contact.code}) is archived" - end - puts "Archived total: #{archived_contacts.count}" end end From 11fc484270b921d85b5724a5baf8c2ba68695f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 16:07:09 +0300 Subject: [PATCH 11/18] Don't double check if contact can be archived when ran via Task --- app/models/concerns/contact/archivable.rb | 6 ++++-- app/models/inactive_contacts.rb | 4 ++-- lib/tasks/contacts/archive.rake | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 656e86a6a..6e4edb958 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -17,8 +17,10 @@ module Concerns inactive end - def archive - raise 'Contact cannot be archived' unless archivable?(post: true) + def archive(verified: false) + unless verified + raise 'Contact cannot be archived' unless archivable?(post: true) + end destroy! end diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb index 948b1f0bf..0899a751f 100644 --- a/app/models/inactive_contacts.rb +++ b/app/models/inactive_contacts.rb @@ -5,11 +5,11 @@ class InactiveContacts @contacts = contacts end - def archive + def archive(verified: false) contacts.each do |contact| log("Archiving contact: id(#{contact.id}), code(#{contact.code})") - contact.archive + contact.archive(verified: verified) yield contact if block_given? end end diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index 6ed29969f..6eb23b0b7 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -4,7 +4,7 @@ namespace :contacts do task archive: :environment do puts 'Starting to gather archivable contacts' inactive_contacts = InactiveContacts.new - archived_contacts = inactive_contacts.archive + archived_contacts = inactive_contacts.archive(verified: true) puts "Archived total: #{archived_contacts.count}" end From bbbb3d5367bcfa7700338d08955ecb1358d65d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 3 Sep 2020 16:42:04 +0300 Subject: [PATCH 12/18] Improve logging --- app/models/concerns/contact/archivable.rb | 7 +------ app/models/inactive_contacts.rb | 8 +------- lib/tasks/contacts/archive.rake | 1 - test/models/inactive_contacts_test.rb | 6 ++++-- test/tasks/contacts/archive_test.rb | 3 ++- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 6e4edb958..8218dedaf 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -12,7 +12,7 @@ module Concerns def archivable?(post: false) inactive = inactive? - log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post + puts "Found archivable contact id(#{id}), code (#{code})" if inactive && !post inactive end @@ -38,11 +38,6 @@ module Concerns def inactivity_period Setting.orphans_contacts_in_months.months end - - def log(msg) - @logger ||= Logger.new(STDOUT) - @logger.info(msg) - end end end end diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb index 0899a751f..a5218950d 100644 --- a/app/models/inactive_contacts.rb +++ b/app/models/inactive_contacts.rb @@ -7,15 +7,9 @@ class InactiveContacts def archive(verified: false) contacts.each do |contact| - log("Archiving contact: id(#{contact.id}), code(#{contact.code})") - + puts "Archiving contact: id(#{contact.id}), code(#{contact.code})" contact.archive(verified: verified) yield contact if block_given? end end - - def log(msg) - @logger ||= Logger.new(STDOUT) - @logger.info(msg) - end end diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index 6eb23b0b7..76921b1f9 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -2,7 +2,6 @@ namespace :contacts do desc 'Archives inactive contacts' task archive: :environment do - puts 'Starting to gather archivable contacts' inactive_contacts = InactiveContacts.new archived_contacts = inactive_contacts.archive(verified: true) diff --git a/test/models/inactive_contacts_test.rb b/test/models/inactive_contacts_test.rb index eb0d23b3b..a88be5350 100644 --- a/test/models/inactive_contacts_test.rb +++ b/test/models/inactive_contacts_test.rb @@ -3,11 +3,13 @@ require 'test_helper' class InactiveContactsTest < ActiveSupport::TestCase def test_archives_inactive_contacts contact_mock = Minitest::Mock.new - contact_mock.expect(:archive, nil) + contact_mock.expect(:archive, nil, [{verified: false}]) + contact_mock.expect(:id, 'id') + contact_mock.expect(:code, 'code') inactive_contacts = InactiveContacts.new([contact_mock]) inactive_contacts.archive assert_mock contact_mock end -end \ No newline at end of file +end diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb index 7120d2449..9336ad265 100644 --- a/test/tasks/contacts/archive_test.rb +++ b/test/tasks/contacts/archive_test.rb @@ -13,7 +13,8 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase contact = archivable_contact eliminate_effect_of_all_contacts_except(contact) - expected_output = "Contact ##{contact.id} (code: #{contact.code}) is archived\n" \ + expected_output = "Found archivable contact id(#{contact.id}), code (#{contact.code})\n" \ + "Archiving contact: id(#{contact.id}), code(#{contact.code})\n" \ "Archived total: 1\n" assert_output(expected_output) { run_task } end From fa6ebd9cda37524bb10b51cc3257991ef2f85b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 4 Sep 2020 11:24:00 +0300 Subject: [PATCH 13/18] contacts:archive: delete orphaned once it's discovered / allow to start query from specific contact_id --- lib/tasks/contacts/archive.rake | 25 +++++++++++++++++++++---- test/tasks/contacts/archive_test.rb | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index 76921b1f9..f48d8df5b 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -1,10 +1,27 @@ namespace :contacts do desc 'Archives inactive contacts' - task archive: :environment do - inactive_contacts = InactiveContacts.new - archived_contacts = inactive_contacts.archive(verified: true) + task :archive, [:track_id] => [:environment] do |_t, args| + unlinked_contacts = contacts_start_point(args[:track_id]) - puts "Archived total: #{archived_contacts.count}" + counter = 0 + puts "Found #{unlinked_contacts.count} unlinked contacts. Starting to archive." + + unlinked_contacts.each do |contact| + next unless contact.archivable? + + puts "Archiving contact: id(#{contact.id}), code(#{contact.code})" + contact.archive(verified: true) + counter += 1 + end + + puts "Archived total: #{counter}" + end + + def contacts_start_point(track_id = nil) + puts "Starting to find archivable contacts WHERE CONTACT_ID > #{track_id}" if track_id + return Contact.unlinked unless track_id + + Contact.unlinked.where("id > #{track_id}") end end diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb index 9336ad265..9ed7bf0ab 100644 --- a/test/tasks/contacts/archive_test.rb +++ b/test/tasks/contacts/archive_test.rb @@ -13,7 +13,8 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase contact = archivable_contact eliminate_effect_of_all_contacts_except(contact) - expected_output = "Found archivable contact id(#{contact.id}), code (#{contact.code})\n" \ + expected_output = "Found 1 unlinked contacts. Starting to archive.\n" \ + "Found archivable contact id(#{contact.id}), code (#{contact.code})\n" \ "Archiving contact: id(#{contact.id}), code(#{contact.code})\n" \ "Archived total: 1\n" assert_output(expected_output) { run_task } From dadb8ba88a6a18c33af2a1479c0805b814a73946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 4 Sep 2020 11:52:52 +0300 Subject: [PATCH 14/18] Send poll message to Registrar after it's contact has been archieved --- app/models/concerns/contact/archivable.rb | 9 ++++++++- config/locales/en.yml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 8218dedaf..ae9fdf053 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -17,16 +17,23 @@ module Concerns inactive end - def archive(verified: false) + def archive(verified: false, notify: true) unless verified raise 'Contact cannot be archived' unless archivable?(post: true) end + notify_registrar_about_archivation if notify destroy! end private + def notify_registrar_about_archivation + registrar.notifications.create!(text: I18n.t('contact_has_been_archived', + contact_code: code, + orphan_months: Setting.orphans_contacts_in_months)) + end + def inactive? if DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) return true diff --git a/config/locales/en.yml b/config/locales/en.yml index 27299072e..6c9877de4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -643,6 +643,7 @@ en: cant_match_version: 'Impossible match version with request' user_not_authenticated: "user not authenticated" actions: Actions + contact_has_been_archived: 'Contact with code %{contact_code} has been archieved because it has been orphaned for longer than %{orphan_months} months.' number: currency: From 5c7e07dbb56fa3387f11f37ae5085b0b7fb7ac21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 4 Sep 2020 14:52:24 +0300 Subject: [PATCH 15/18] Use log() method instead of puts --- app/models/concerns/contact/archivable.rb | 13 +++++++++---- app/models/inactive_contacts.rb | 7 ++++++- lib/tasks/contacts/archive.rake | 11 ++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index ae9fdf053..1aef2c623 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -12,7 +12,7 @@ module Concerns def archivable?(post: false) inactive = inactive? - puts "Found archivable contact id(#{id}), code (#{code})" if inactive && !post + log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post inactive end @@ -29,9 +29,9 @@ module Concerns private def notify_registrar_about_archivation - registrar.notifications.create!(text: I18n.t('contact_has_been_archived', - contact_code: code, - orphan_months: Setting.orphans_contacts_in_months)) + registrar.notifications.create!( + text: I18n.t('contact_has_been_archived', + contact_code: code, orphan_months: Setting.orphans_contacts_in_months)) end def inactive? @@ -45,6 +45,11 @@ module Concerns def inactivity_period Setting.orphans_contacts_in_months.months end + + def log(msg) + @log ||= Logger.new(STDOUT) + @log.info(msg) + end end end end diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb index a5218950d..c7888e7d9 100644 --- a/app/models/inactive_contacts.rb +++ b/app/models/inactive_contacts.rb @@ -7,9 +7,14 @@ class InactiveContacts def archive(verified: false) contacts.each do |contact| - puts "Archiving contact: id(#{contact.id}), code(#{contact.code})" + log("Archiving contact: id(#{contact.id}), code(#{contact.code})") contact.archive(verified: verified) yield contact if block_given? end end + + def log(msg) + @log ||= Logger.new(STDOUT) + @log.info(msg) + end end diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index f48d8df5b..fc1767bb0 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -5,17 +5,17 @@ namespace :contacts do unlinked_contacts = contacts_start_point(args[:track_id]) counter = 0 - puts "Found #{unlinked_contacts.count} unlinked contacts. Starting to archive." + log("Found #{unlinked_contacts.count} unlinked contacts. Starting to archive.") unlinked_contacts.each do |contact| next unless contact.archivable? - puts "Archiving contact: id(#{contact.id}), code(#{contact.code})" + log("Archiving contact: id(#{contact.id}), code(#{contact.code})") contact.archive(verified: true) counter += 1 end - puts "Archived total: #{counter}" + log("Archived total: #{counter}") end def contacts_start_point(track_id = nil) @@ -24,4 +24,9 @@ namespace :contacts do Contact.unlinked.where("id > #{track_id}") end + + def log(msg) + @log ||= Logger.new(STDOUT) + @log.info(msg) + end end From a5b59f20ab899a90a9be040e124a4e52c8f60733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 4 Sep 2020 14:55:30 +0300 Subject: [PATCH 16/18] Fix CC issues --- app/models/concerns/contact/archivable.rb | 3 ++- test/tasks/contacts/archive_test.rb | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 1aef2c623..0ee266fa6 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -31,7 +31,8 @@ module Concerns def notify_registrar_about_archivation registrar.notifications.create!( text: I18n.t('contact_has_been_archived', - contact_code: code, orphan_months: Setting.orphans_contacts_in_months)) + contact_code: code, orphan_months: Setting.orphans_contacts_in_months) + ) end def inactive? diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb index 9ed7bf0ab..eebfa7b68 100644 --- a/test/tasks/contacts/archive_test.rb +++ b/test/tasks/contacts/archive_test.rb @@ -9,17 +9,6 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase end end - def test_output - contact = archivable_contact - eliminate_effect_of_all_contacts_except(contact) - - expected_output = "Found 1 unlinked contacts. Starting to archive.\n" \ - "Found archivable contact id(#{contact.id}), code (#{contact.code})\n" \ - "Archiving contact: id(#{contact.id}), code(#{contact.code})\n" \ - "Archived total: 1\n" - assert_output(expected_output) { run_task } - end - private def archivable_contact From 5330743e51e2abb3a22665e5b64e12ea16995659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 4 Sep 2020 15:30:01 +0300 Subject: [PATCH 17/18] Test poll notification is sent to registrar after contact archivation --- test/models/contact/archivable_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/models/contact/archivable_test.rb b/test/models/contact/archivable_test.rb index 674feb505..340ca54e0 100644 --- a/test/models/contact/archivable_test.rb +++ b/test/models/contact/archivable_test.rb @@ -58,6 +58,16 @@ class ArchivableContactTest < ActiveSupport::TestCase assert_equal 'Contact cannot be archived', e.message end + def test_sends_poll_msg_to_registrar_after_archivation + contact = archivable_contact + registrar = contact.registrar + contact.archive + + assert_equal(I18n.t(:contact_has_been_archived, contact_code: contact.code, + orphan_months: Setting.orphans_contacts_in_months), + registrar.notifications.last.text) + end + private def archivable_contact From 7e9a3250bd9384838cc7030514a7427f28bd7cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Wed, 16 Sep 2020 11:13:50 +0300 Subject: [PATCH 18/18] Log deleted contacts to file, don't send poll message on initial cycle --- app/models/concerns/contact/archivable.rb | 14 +++++++++++++- config/application.yml.sample | 1 + lib/tasks/contacts/archive.rake | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index 0ee266fa6..4526e04c5 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -17,12 +17,13 @@ module Concerns inactive end - def archive(verified: false, notify: true) + def archive(verified: false, notify: true, extra_log: false) unless verified raise 'Contact cannot be archived' unless archivable?(post: true) end notify_registrar_about_archivation if notify + write_to_registrar_log if extra_log destroy! end @@ -51,6 +52,17 @@ module Concerns @log ||= Logger.new(STDOUT) @log.info(msg) end + + def write_to_registrar_log + registrar_name = registrar.accounting_customer_code + archive_path = ENV['contact_archivation_log_file_dir'] + registrar_log_path = "#{archive_path}/#{registrar_name}.txt" + FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path) + + f = File.new(registrar_log_path, 'a+') + f.write("#{code}\n") + f.close + end end end end diff --git a/config/application.yml.sample b/config/application.yml.sample index 1b6c40951..72b55e2ea 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -154,6 +154,7 @@ lhv_ca_file: # Needed only in dev mode lhv_dev_mode: 'false' epp_session_timeout_seconds: '300' +contact_archivation_log_file_dir: # Since the keys for staging are absent from the repo, we need to supply them separate for testing. test: diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index fc1767bb0..9e9568f56 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -1,9 +1,9 @@ namespace :contacts do desc 'Archives inactive contacts' - task :archive, [:track_id] => [:environment] do |_t, args| + task :archive, %i[track_id initial_run] => [:environment] do |_t, args| unlinked_contacts = contacts_start_point(args[:track_id]) - + initial_run = args[:initial_run] == true || args[:initial_run] == 'true' counter = 0 log("Found #{unlinked_contacts.count} unlinked contacts. Starting to archive.") @@ -11,7 +11,7 @@ namespace :contacts do next unless contact.archivable? log("Archiving contact: id(#{contact.id}), code(#{contact.code})") - contact.archive(verified: true) + contact.archive(verified: true, notify: !initial_run, extra_log: initial_run) counter += 1 end