Problem/Motivation
Right now, the module displays a summary of the pending changes just like on the Drupal status page, but this summary doesn't explain what about each field or entity has actually changed. This makes it difficult if this module is not able to automatically apply updates but you still need to know what the schema differences are so that you can fix them yourself. Is there any plan to extend this module to provide effectively like a field/entity schema diff to make this easier?
<!--break-->
The motivation for this feature request is that a site we are maintaining has field and entity schema changes that resulted from having to carefully remove Multiversion several versions back (we removed it back when we were on Drupal 8 and are now running Drupal 9.3 and preparing for Drupal 10). With Multiversion removed, the site is running fine with the exception of the "Mismatched entity and/or field definitions" error on the status page, but we want to fix up this technical debt in case it causes problems in a future Drupal version. It looks like what's happened is that the database tables were updated to remove the extra fields that Multiversion was maintaining, but the entity schema in the key_value
table still refers to the tables and fields that Multiversion added (e.g., comment_revision
, comment_field_revision
, etc.), resulting in the errors on the status page. Devel Entity Update can't fix this because the database tables are out-of-sync with the schema AND some of the updates that need to be done violate Drupal business rules regarding fields that already contain data.
Another use case for this is during development -- it would be great if a dev making changes to the schema could just run a command that lists what's changed between the active and last-installed entity/field schema, so they know what updates to write.
Having stepped through the code of this module, I understand how difficult Core makes it to get this level of data about the schema, since most of this functionality is handled by protected methods inside \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema
, but it would still be great if there's a way to get precisely why the error about updates is appearing on the status page.
Proposed resolution
Implement a new command that can print a list of diffs for the changes that need to be applied to fields and entities (e.g., delete field X
, make field Y
revisionable, stop referencing table A
in the field definition for field Z
).
Remaining tasks
User interface changes
API changes
Data model changes