Consider adding hook_entity_schema_alter()

Created on 5 May 2014, almost 11 years ago
Updated 24 April 2025, 2 days ago

Problem/Motivation

#2183231: Make ContentEntityDatabaseStorage generate static database schemas for content entities β†’ will add automatic entity schemas but will remove the ability to dynamically alter schemas with hook_schema_alter().

Modules adding fields to entities might want to add multi-field indexes and thus need to alter the schema.

Proposed resolution

Remaining tasks

User interface changes

API changes

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

Live updates comments and jobs are added and updated live.
  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡·πŸ‡΄Romania amateescu

    This is still needed.

  • First commit to issue fork.
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    I'm not so sure. I don't think the entity schema is an API, which having an alter hook for would kind of imply that. Entity types own their schema and they can alter it through the storage schema handler.

    You can't add something to the schema and expect it to work, you'd still need an update function to apply it. We need something to manage indexes better, but I think that should be on the field storage/type definition level.

    Won't fix IMHO.

  • πŸ‡¬πŸ‡§United Kingdom catch

    I mostly agree with #33 but it would be good to link to the right issue to track the need for managing/customising indexes. The problem here is still valid it's just the solution is not really the right place.

    I had a look and ✨ Field type modules cannot maintain their field schema (field type schema change C(R)UD is needed) Needs work or πŸ› Adding an index to an entity's schema is not detected as a change in onEntityTypeUpdate Active are both pretty close. Happy for someone else to close this out, but also leaving opening for now in case this triggers a memory of any more potential duplicates.

Production build 0.71.5 2024