Create EntityType model, migrate data, and update API endpoints
The main goal is to introduce the EntityType
model, migrate existing types to it, and update the existing endpoints to use this new model.
The model arkindex.documents.EntityType
has the following configuration:
- UUID PK
- charfield name, max length of 250
- charfield color, max length of 6, default to 'FF0000' (red as HTML codes)
- a Foreign Key towards Corpus
- usual created / updated dates
- a unique together constraint on
name + corpus
The data migration must convert all existing entity types (corpus by corpus), only creating the necessary types (no need to create entity types if they are unused). The migration should assign the existing colors used by the frontend for the different static types, as to maintain the same visual output (no need to generate fancy colors here).
Concerning the subtype
metas available on any entity, the meta value should become the name of the newly created Entity type. For example, if an entity of type Misc
, with metas subtype = Human
, the EntityType.name
must be Human
.
Finally, you need to update the following API endpoints in order to maintain usage by the frontend and API users (workers mostly):
- RetrieveEntity
- use a light serializer to expose ID, name and color
- ListCorpusEntities
- use a light serializer to expose ID, name and color
- ListEntityElements
- use a light serializer to expose ID, name and color
- CreateEntity
- the
type
field should now support either an UUID or name (do not create entity type if missing)
- the
- (Partial)UpdateEntity
- the
type
field should now support either an UUID or name (do not create entity type if missing)
- the