New command to merge entities
Refs https://gitlab.com/arkindex/requests/-/issues/716
We need a new django command named merge_entities
that simply takes a corpus ID as input and then merges all similar entities.
This means all entities with the same type+name+value would be merged into a single one.
I suggest:
- making a query to list all duplicates entities (maybe easier with a raw sql and a group by, but it should be possible with django aggregation)
- listing all cases, taking the first available one as the new "source"
- updating all other references to that one
- removing all deprecated entities