From 74f39cf8ad59a9744e49dcf85f0b9afc784506f2 Mon Sep 17 00:00:00 2001 From: stevenjcumming <134282106+stevenjcumming@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:51:44 -0400 Subject: [PATCH] Remove Data Column From Personal Information Log (#16300) * remove data column from personal info log * remove missing data error test * rubocop formatting * reorder personal info log data keys in spec * add personal_information_log.rb to CODEOWNERS * update CODEOWNERS for lib/common/client/middleware * add personal_information_log.rb model to CODEOWNERS --- .github/CODEOWNERS | 4 +++- app/models/personal_information_log.rb | 2 +- .../20240411152758_drop_data_in_personal_information_log.rb | 5 +++++ db/schema.rb | 1 - spec/lib/common/client/middleware/logging_spec.rb | 2 +- spec/models/personal_information_log_spec.rb | 4 ++-- 6 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20240411152758_drop_data_in_personal_information_log.rb diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3553e4a63b9..e423dd2a2d3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -282,6 +282,7 @@ app/models/persistent_attachment.rb @department-of-veterans-affairs/benefits-no app/models/persistent_attachments/dependency_claim.rb @department-of-veterans-affairs/benefits-dependents-management @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/persistent_attachments/lgy_claim.rb @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/persistent_attachments/pension_burial.rb @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/pensions @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group +app/models/personal_information_log.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/power_of_attorney.rb @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/prescription_preference.rb @department-of-veterans-affairs/vfs-mhv-medications @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @@ -1291,7 +1292,7 @@ spec/lib/claim_status_tool @department-of-veterans-affairs/benefits-management-t spec/lib/common/client/concerns/mhv_fhir_session_client_spec.rb @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/lib/common/client/concerns/mhv_locked_session_client_spec.rb @department-of-veterans-affairs/vfs-mhv-medical-records @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group -spec/lib/common/client/middleware/response @department-of-veterans-affairs/backend-review-group +spec/lib/common/client/middleware @department-of-veterans-affairs/backend-review-group spec/lib/debt_management_center @department-of-veterans-affairs/vsa-debt-resolution @department-of-veterans-affairs/backend-review-group spec/lib/decision_review @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/lib/disability_compensation @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @@ -1460,6 +1461,7 @@ spec/models/mhv_opt_in_flag_spec.rb @department-of-veterans-affairs/vfs-mhv-secu spec/models/mpi_data_spec.rb @department-of-veterans-affairs/octo-identity spec/models/onsite_notification_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/persistent_attachments @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/pensions @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group +spec/models/personal_information_log_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/prescription_spec.rb @department-of-veterans-affairs/vfs-mhv-medications @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/prescription_details_spec.rb @department-of-veterans-affairs/vfs-mhv-medications @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group diff --git a/app/models/personal_information_log.rb b/app/models/personal_information_log.rb index c62c30516ee..722560381d8 100644 --- a/app/models/personal_information_log.rb +++ b/app/models/personal_information_log.rb @@ -4,7 +4,7 @@ class PersonalInformationLog < ApplicationRecord scope :last_week, -> { where('created_at >= :date', date: 1.week.ago) } has_kms_key - has_encrypted :data, migrating: true, type: :json, key: :kms_key, **lockbox_options + has_encrypted :data, type: :json, key: :kms_key, **lockbox_options validates :error_class, presence: true end diff --git a/db/migrate/20240411152758_drop_data_in_personal_information_log.rb b/db/migrate/20240411152758_drop_data_in_personal_information_log.rb new file mode 100644 index 00000000000..0bac274cc6f --- /dev/null +++ b/db/migrate/20240411152758_drop_data_in_personal_information_log.rb @@ -0,0 +1,5 @@ +class DropDataInPersonalInformationLog < ActiveRecord::Migration[7.1] + def change + safety_assured { remove_column :personal_information_logs, :data, :jsonb } + end +end diff --git a/db/schema.rb b/db/schema.rb index 37726024dfc..b4e248bd815 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -931,7 +931,6 @@ end create_table "personal_information_logs", id: :serial, force: :cascade do |t| - t.jsonb "data", null: false t.string "error_class", null: false t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false diff --git a/spec/lib/common/client/middleware/logging_spec.rb b/spec/lib/common/client/middleware/logging_spec.rb index 3a72d45d141..5a7cd47faca 100644 --- a/spec/lib/common/client/middleware/logging_spec.rb +++ b/spec/lib/common/client/middleware/logging_spec.rb @@ -20,7 +20,7 @@ it 'creates a new personal information log record' do expect { client.get('success') }.to change(PersonalInformationLog, :count).by(1) - expect(PersonalInformationLog.last.data.keys).to eq(%w[url method request_body response_body]) + expect(PersonalInformationLog.last.data.keys).to eq(%w[method url request_body response_body]) end it 'correctly records (no) request body on a GET request' do diff --git a/spec/models/personal_information_log_spec.rb b/spec/models/personal_information_log_spec.rb index 42b0dde1ea3..4d9cfff7e39 100644 --- a/spec/models/personal_information_log_spec.rb +++ b/spec/models/personal_information_log_spec.rb @@ -26,8 +26,8 @@ context 'when data is missing' do let(:pi_log) { build(:personal_information_log, data: nil) } - it 'raises PG::NotNullViolation error' do - expect { pi_log.save }.to raise_error(ActiveRecord::NotNullViolation) + it 'does not raise error' do + expect { pi_log.save }.not_to raise_error end end