Skip to content

Commit

Permalink
FSPT-208: script to make nested JSON date strings consistent
Browse files Browse the repository at this point in the history
For a ~2 week period application `date_submitted` properties were
incorrectly set with timezone information (in this case consistently UTC
with `+00.00`).

The consumer of these dates (the assess tool) has been updated in places
to parse any valid ISO format but leaving different formats of dates
could lead to unpredictiable behaviour.

Update existing assessment records to make this consistent.
  • Loading branch information
sfount committed Jan 8, 2025
1 parent 0e44fb3 commit 1b8a2bc
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
begin;

/* Check the result is {some} */
select count(*) from assessment_records where jsonb_blob->>'date_submitted' like '%+00.00';

/* Check we've updated {some} */
update assessment_records
set jsonb_blob['date_submitted'] = to_jsonb(replace(jsonb_blob->>'date_submitted', '+00.00', ''))
where jsonb_blob->>'date_submitted' like '%+00.00';

/* Check the result is 0 */
select count(*) from assessment_records where jsonb_blob->>'date_submitted' like '%+00.00';

/* Only commit if everything lined up as expected */
commit;

0 comments on commit 1b8a2bc

Please sign in to comment.