Provide a flag to allow updates to stored schema for fields

Created on 5 December 2023, 12 months ago
Updated 8 April 2024, 7 months ago

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 πŸ› Timestamp field items are affected by 2038 bug Needs work 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 πŸ› Timestamp field items are affected by 2038 bug Needs work

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.

✨ Feature request
Status

Fixed

Version

10.3 ✨

Component
FieldΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡¨πŸ‡¦Canada mandclu

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024