Skip to content

Commit

Permalink
Merge pull request #1169 from internetee/remove-unused-columns-from-l…
Browse files Browse the repository at this point in the history
…og-domains

Remove unused columns from `log_domains` database table
  • Loading branch information
vohmar authored Apr 24, 2019
2 parents ee20535 + 008bf81 commit 59d6e3e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions app/models/legal_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -4942,3 +4939,5 @@ INSERT INTO schema_migrations (version) VALUES ('20190322152123');

INSERT INTO schema_migrations (version) VALUES ('20190322152529');

INSERT INTO schema_migrations (version) VALUES ('20190415120246');

5 changes: 2 additions & 3 deletions test/system/admin_area/domain_versions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59d6e3e

Please sign in to comment.