I have a Spring Boot webapp with a MySQL database. I'm trying to replicate this data into a MSSQL for running reports against.
All rows are audited with created_at and modified_at datetimes so i can easily fetch new and changed rows. Problem is when a row is deleted this will not be reflected in the target database.
From the top of my head there's a couple of ways to solving this
- Triggers and a "history" table. Whenever there's an update to the table, it inserts a copy of the row and a column describing the action taken.
- A deleted bit. 1 is a deleted row (this will have me redo all queries though, and now i see the advantage of having a class in between the controller and the repository)
- And the very verbose method of querying all rows and check what's missing (will not do)
Is there a right way of handling this?