Ability to Show the Differences between Active and Installed Entity/Field Schema

Created on 23 November 2022, about 2 years ago
Updated 15 November 2023, about 1 year ago

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

✨ Feature request
Status

Active

Version

4.0

Component

Base system

Created by

πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΉAustria mvonfrie

    I really like to see this as well, no matter where it will be implemented. I currently have an issue with updating json_field from 1.0-RC4 to 1.0 or even 1.2, which is caused by the fix for #3252426 πŸ› Support sqlite; set sqlite_type to native JSON field Fixed . This module cannot update the fields automatically because they have contents. In this case that should not matter because the change is about the SqlLite data type and I'm not using SqlLite.

Production build 0.71.5 2024