From 008bf8102de3d885139bf2b1b22de16028505feb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Apr 2019 15:12:52 +0300 Subject: [PATCH] Remove unused columns from `log_domains` database table --- app/models/legal_document.rb | 3 +-- ...0190415120246_remove_unused_columns_from_log_domains.rb | 7 +++++++ db/structure.sql | 5 ++--- test/system/admin_area/domain_versions_test.rb | 5 ++--- 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20190415120246_remove_unused_columns_from_log_domains.rb diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index 4d75d272d9..630c52d986 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -87,8 +87,7 @@ def self.remove_duplicates contact_ids = DomainVersion.where(item_id: orig_legal.documentable_id).distinct. pluck("object->>'registrant_id'", "object_changes->>'registrant_id'", - "children->>'tech_contacts'", "children->>'admin_contacts'", - "tech_contact_ids", "admin_contact_ids").flatten.uniq + "children->>'tech_contacts'", "children->>'admin_contacts'").flatten.uniq contact_ids = contact_ids.map{|id| case id when Hash diff --git a/db/migrate/20190415120246_remove_unused_columns_from_log_domains.rb b/db/migrate/20190415120246_remove_unused_columns_from_log_domains.rb new file mode 100644 index 0000000000..d92b0c7c61 --- /dev/null +++ b/db/migrate/20190415120246_remove_unused_columns_from_log_domains.rb @@ -0,0 +1,7 @@ +class RemoveUnusedColumnsFromLogDomains < ActiveRecord::Migration + def change + remove_column :log_domains, :nameserver_ids + remove_column :log_domains, :admin_contact_ids + remove_column :log_domains, :tech_contact_ids + end +end \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 08ed08c47b..1494ab295c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1539,9 +1539,6 @@ CREATE TABLE public.log_domains ( object jsonb, object_changes json, created_at timestamp without time zone, - nameserver_ids text[] DEFAULT '{}'::text[], - tech_contact_ids text[] DEFAULT '{}'::text[], - admin_contact_ids text[] DEFAULT '{}'::text[], session character varying, children json, uuid character varying @@ -4940,3 +4937,5 @@ INSERT INTO schema_migrations (version) VALUES ('20190322152123'); INSERT INTO schema_migrations (version) VALUES ('20190322152529'); +INSERT INTO schema_migrations (version) VALUES ('20190415120246'); + diff --git a/test/system/admin_area/domain_versions_test.rb b/test/system/admin_area/domain_versions_test.rb index ba07db3f72..f93e2b153a 100644 --- a/test/system/admin_area/domain_versions_test.rb +++ b/test/system/admin_area/domain_versions_test.rb @@ -29,12 +29,11 @@ def create_domain_with_history VALUES (54, 54, '2018-06-23T12:14:02.732+03:00', 54, 'transfer_code'); INSERT INTO log_domains (item_type, item_id, event, whodunnit, object, - object_changes, created_at, nameserver_ids, tech_contact_ids, - admin_contact_ids, session, children) + object_changes, created_at, session, children) VALUES ('Domain', 54, 'update', '1-AdminUser', '{"id": 54, "registrar_id": 54, "valid_to": "2018-07-23T12:14:05.583+03:00", "registrant_id": 54, "transfer_code": "transfer_code", "valid_from": "2017-07-23T12:14:05.583+03:00"}', '{"foo": "bar", "other_made_up_field": "value"}', - '2018-04-23 15:50:48.113491', '{}', '{}', '{}', '2018-04-23 12:44:56', + '2018-04-23 15:50:48.113491', '2018-04-23 12:44:56', '{"null_fracdmin_contacts":[108],"tech_contacts":[109],"nameservers":[],"dnskeys":[],"legal_documents":[null],"registrant":[1]}' ) SQL