Use a UUID for the TranscriptionEntity primary key
https://redmine.teklia.com/issues/7696
We created TranscriptionEntity without specifying a primary key field, so Django created an AutoField (an integer). To be consistent with the other ML results and simplify re-importing exports, we need to replace that field with an UUIDField.
-
Add the usual
id = UUIDField(...)onTranscriptionEntity. -
Just like in
process.0023, have the migration use aRunSQLwhosestate_operationsinclude updating the type of theidfield.-
Use
gen_random_uuid()to generate the new UUIDs to reset the column. -
For databases that were created after Django 4.1, the
idcolumn will useGENERATED BY DEFAULT AS IDENTITY, a constraint that must be removed before you can change the type. You can useDROP IDENTITY IF EXISTSon the column to clean it up. -
For databases that existed before Django 4.1, there will be a
documents_transcriptionentity_id_seqsequence that you need to drop manually if it exists. -
This migration is reversible, and easier to do using the old method before Django 4.1:
- Create the
documents_transcriptionentity_id_seq. No need to override any defaults on it. - Reset the field type to
int, this timeUSING nextval('documents_transcriptionentity_id_seq'::regclass). - Set the same
nextvalcall as the default value for the column, so that the sequence is used when inserting new rows.
- Create the
-
-
Update the export structure to have
transcription_entity.idbe aVARCHAR(37), and bump the export version. -
Update the maximum supported version in
load_export. Previous versions should still be compatible.