HHS / simpler-grants-gov

https://simpler.grants.gov
Other
42 stars 11 forks source link

[Task]: Adjust transformation logic to handle cascading delete scenarios #1983

Closed chouinar closed 1 week ago

chouinar commented 4 months ago

Summary

Lets assume the following scenario. We previously imported and opportunity, synopsis, and a few applicant types for that synopsis.

That opportunity record gets deleted in the Oracle database. In Oracle, what will happen is that a record will be removed from the opportunity/synopsis/applicant type tables, and created in the equivalent history tables.

In our load process, we'll mark all of the non-history table rows as is_deleted=True and then in the transformation process we'll try to delete the records.

When we process the opportunity record, we delete it, and SQLAlchemy even handles deleting all of the children (the opportunity summary, and applicant types) for us. However, when we then try to process the delete events for the synopsis and applicant type records, it will error because we already deleted them. When a record errors, we continue processing, but leave that one alone, meaning it would keep occurring.

--

We need to do something to adjust this logic. A few options:

Acceptance criteria

chouinar commented 1 week ago

This was implemented in the fork that we recently merged in: https://github.com/HHS/simpler-grants-gov/commit/c154c52260e3a8a5ed989f056b7969f172c79971