-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
False
-
-
False
-
-
Investigating SWATCH-3478, we found that we have almost 1 M records in tally_snapshots that are not linked to any customer (org_id is null).
We need to purge these records that are not going to be deleted by the clean up cronjob (which is org_id/timestamp based).
Query that can be used:
select * from tally_snapshots where org_id is null
The most recent tally_snapshot without org_id in production is from 2023-01-03, so this was likely to be caused by an old bug that has been already addressed.
Note that the tally_measurements records that are using any of these tally_snapshots need also to be deleted. And take into account that since we don't use a foreign key from tally_snapshots to tally_measurements, we can't use delete cascade, so we need to delete the tally_measurements before deleting the tally_snapshots.
Acceptance Criteria
- Delete the tally_measurements and tally_snapshots
- Add non null constraint for the org_id column
- If a liquibase migration script is used, double check that it will finish ok in a certain amount of time. Otherwise, ask for support for DBA to run the delete queries.
In stage, there are less than 1 M tally snapshots records, and only 132 without org_id
In prod, there are more than 164 M tally snapshots records, and almost 1 M records without org_id.
- blocks
-
SWATCH-3478 Correct tally_snapshot table constraints
-
- Backlog
-