Updated migrations to handle unparseable data#534
Conversation
… after switch back to JSONField.
8ba67a6 to
a7fda0e
Compare
Do you feel like you have a solid understanding of how we are getting ourselves into these types of situations? Shouldn't we also add some logic into the application to ensure that we don't find ourselves back in this same situation in the future? |
|
Yeah, that's a good point. I haven't updated the DOI Matching process to alter the data we insert into the DB. At a glance, the DOI Matcher still serializes all the data. I'll check if that matters in this context or if that's to be expected, since the DOI Matcher creates Change objects and stores everything in the The only references I see to |
This confuses me a bit. What is this encoding? |
The double escaping is the result of the issue around the model form passing a string to json.dumps (#389). I made a mistake in thinking I had to correct that |
Also reconvert data after switching columns back to JSONField.
This PR addresses a couple of issues with the previous attempt to store CMR data as JSON:
I've run this on a dump of the production DB and it works correctly, with the exception of one record, which has an unparseable "false" value. My recommendation is to restore the staging DB from a dump of the production DB prior to deploying this and manually update that record, since it appears to be an anomaly:
Also of note: the
cmr_data_formatscolumn contains inconsistently formatted data. In some cases, it stores an array of strings and in others it stores a single string. The updated migration will force a single string to be stored as an array, which I think makes sense given the name of the column.