Active development on the entity storage layer has mostly stalled since 2015, and the number of subtle bugs and @todos in code are clearly showing the amount technical debt that we're dealing with.
The end goal of this plan is to allow alternative (non-)SQL storage and table layout implementations in contrib without forcing them to re-implement all the storage / entity query / views integration code. I think we can achieve this by removing the notions (and core usages) of entity base / data / revision / revision_data / dedicated tables, and replace them with the general notion that "everything is a field table".
Step 1: Finalize the Table Mapping API
- #2916018: Allow the table mapping to be initialized from outside the storage
- #2981220: SqlContentEntityStorage should use the table names provided by its table mapping
- #2955442: Add a way to get all the tables in which a field is stored from TableMappingInterface
- #2960037: Add a way to get the primary table of an entity type from TableMappingInterface
- #2960046: Allow the table mapping to be instantiated with a custom entity type definition
- #2960136: Add the ability to use a prefix for all the tables in a table mapping
- #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data
Step 2: Update core to use the new API
After completing the table mapping API, we should be able to start on cleaning up all the places that still use D7-style logic when dealing with the entity storage as well as long standing @todo's and bug reports.
Specifically, we should be able to:
- use the last installed entity type and field storage definitions during entity type / field storage CRUD operations, fixing things like #2914875: Rebuilding of table mapping in entity storage on shared field creation breaks initial value handling and #2705205: Improve test coverage around updating table mapping after a new field storage definition is added
- rewrite the entity query's table selection to use the data table as the base table, improving performance for most queries: #2875033: Optimize joins and table selection in SQL entity query implementation
- rewrite the views data and queries to not rely on the tables defined in the entity type definition
- fix #2274017: Make SqlContentEntityStorage table mapping agnostic
- probably many other cleanups
And all that while also having the abilty to swap the table mapping to an entirely custom implementation, for example one that uses a single table to store all the revision/translation/multi-value field data, like the Entity Storage JSON module :)
Comments
Comment #2
amateescu commentedThe first blocker issue is in! #2916018: Allow the table mapping to be initialized from outside the storage
Next on the priority list is #2955442: Add a way to get all the tables in which a field is stored from TableMappingInterface.
And here's the kind of cleanup that is enabled by the new capabilities of the table mapping API: #2960497: Simplify SqlContentEntityStorage::countFieldData()
Comment #3
amateescu commentedUpdating the IS with some progress!
Comment #4
amateescu commentedAdded #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data to the list.
Comment #6
plachRelated issue: #2401107: Consider generalizing DefaultTableMapping