Problem/Motivation
Drupal's powerful field system keeps a copy of the schema. Contrib modules are able to update fields in the database, especially to increase column size, even if the field has data. Currently the SqlContentEntityStorageSchema class will refuse to update its stored schema definitions if the field contains data, even if the database columns have already been updated.
This change is also part of the proposed changes in #2885413: Timestamp field items are affected by 2038 bug but is proposed separately here in hopes at least this part could be committed more quickly.
Steps to reproduce
The easiest way to reproduce would be using a contrib module that recently expanded its storage to deal with the Y2038 problem. With a fresh install of Drupal 10, install Smart Date 3.7.x and add a Smart Date field to a content type. Create a node of this type with a value for the Smart Date field. Now, update Smart Date to
Proposed resolution
Add a setting to SqlContentEntityStorageSchema to indicate that the database columns have already been updated, allowing the stored schema to be updated.
Remaining tasks
If this issue gets implemented, the same change should be removed from the MR in #2885413: Timestamp field items are affected by 2038 bug
User interface changes
N/A
API changes
The addition of the column_changes_handled setting could be considered an expansion of the API and should be documented.
Data model changes
N/A
Release notes snippet
Modules needing to update the stored schema for fields that have been increased in size in an update hook can now do so by adding the column_changes_handled setting in the storage definition when calling updateFieldStorageDefinition.
Issue fork drupal-3406172
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mandclu CreditAttribution: mandclu as a volunteer and at Acquia commentedComment #4
smustgrave CreditAttribution: smustgrave at Mobomo commentedWill need test coverage.
Also not sure if this would require an update to the schema
Comment #5
mxr576I see test coverage in the MR now.
Comment #6
mxr576Tested the patch and I can confirm it is working.
Comment #7
alexpottCommitted and pushed fdfb3c6675 to 11.x and e4aafad82b to 10.3.x. Thanks!
Comment #10
Wim LeersIntriguing issue! I wonder if we could piggyback on this this infrastructure in https://www.drupal.org/project/distributions_recipes to allow reverting of DB schema modifications upon applying a recipe (i.e. when installing
FieldStorageConfig
+FieldConfig
) … 🕵️♂️