department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
282 stars 203 forks source link

ActiveRecord::SubclassNotFound - STI data issues #29444

Closed LindseySaari closed 3 years ago

LindseySaari commented 3 years ago

Issue Description

While testing the attr_encrypted key rotation in the dev and staging environments, a few instances of ActiveRecord::SubclassNotFound errors were found.

ActiveRecord::SubclassNotFound (The single-table inheritance mechanism failed to locate the subclass errors for the SavedClaim records

It seems that the type column is from a subclass the no longer exists. With Single Table Inheritance, the type column is used to saved the class name of child classes. Ex: CentralMailClaim < SavedClaim

Ex: run SavedClaim.first in the staging env to see the mentioned issue

It's most likely that we have old data in the type column and it needs to be updated/deleted OR maybe this table is not meant to use STI?

More background information is needed


Tasks

Acceptance Criteria

LindseySaari commented 3 years ago

Staging Findings:

I ran the following: subclasses = SavedClaim.descendants.collect{ |d| d.name }

Thread started here. Hopefully someone has some background information SavedClaim.where("type NOT IN (?)", subclasses).count

There are 156 records that have a type/subclass of something other than a child class of SavedClaim 11616 in prod

LindseySaari commented 3 years ago

Update:

I’ve narrowed down the STI issues with non existing types/subclasses of SavedClaim. There are two types in question: SavedClaim::DisabilityCompensation::Form526IncreaseOnly and SavedClaim::EducationBenefits::VA1995s

For the SavedClaim::DisabilityCompensation::Form526IncreaseOnly records, it looks like SavedClaim::DisabilityCompensation class was removed here. I've asked in the vsa-engineering channel and the vsa-claims-appeals channel. It's believed that these records are stale and can be removed, but need to check with the product owner

The SavedClaim::EducationBenefits::VA1995s was removed in this PR. I've asked in this vsa-education slack channel here. Next step is to see if this data is stale/can be deleted or if we need to migrate it to another class.

LindseySaari commented 3 years ago

According to Daniel Shawkey, the VA1995s records can be deleted