bhima icon indicating copy to clipboard operation
bhima copied to clipboard

Proposal: deprecate document_map and entity_map and use a single uuid_map

Open jniles opened this issue 2 years ago • 1 comments

Right now, we have two tables that essentially map UUIDs to human readable documents. The general rule is the document_map contains documents (invoices, vouchers, receipts, transactions, etc) and entity_map contains entities (employees, patients, etc). Both are simple, identical tables - a binary UUID column and a TEXT column.

I propose we merge these into a single table called uuid_map that will contain a human readable reference for any uuid in the application. This means we'll be able to add:

  1. depot_uuid -> depot name
  2. suppler_uuid -> supplier name
  3. shipment_uuid -> shipment identifier

And any other UUIDs that don't fit cleanly into the definition above. It will also mean that a developer doesn't have to wonder what table the mapping is contained in, or make a decision about what table to put a new record in.

Another big advantage of this method is that we sometimes have columns that can contain either a document or an entity. For example, stock_movement.entity_uuid maps to a person, a depot, or a previous movement. Having a single table to match will remove the ambiguity and simply the code.

jniles avatar Jun 01 '22 19:06 jniles

Note that this could be used to implement Issue 6644.

jmcameron avatar Jun 01 '22 19:06 jmcameron