By amateescu on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.7.x
Introduced in version:
8.7.0
Issue links:
Description:
Starting with Drupal 8.7.0, the Entity system provides a new Update API for converting the schema of a content entity type from (non-)revisionable/(non-)translatable to revisionable/translatable, which also works when there is pre-existing data for the entity type whose schema is being changed.
Note that schema conversions when there is existing data are only supported when executed through a hook_post_update_NAME() implementation, because they need to run in a batch process.
New APIs introduced:
\Drupal\Core\Entity\EntityDefinitionUpdateManagerhas a new method:updateFieldableEntityType(EntityTypeInterface $entity_type, array $field_storage_definitions, array &$sandbox = NULL)\Drupal\Core\Entity\EntityTypeListenerInterfacehas a new method:onFieldableEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original, array $field_storage_definitions, array $original_field_storage_definitions, array &$sandbox = NULL)\Drupal\Core\Entity\EntityStorageInterfacehas a new method:restore(EntityInterface $entity)- a new trait
\Drupal\Core\Entity\Sql\SqlFieldableEntityTypeListenerTraitwas introduced to allow other entity storage implementations to re-use the data copying logic
Example conversions from a non-revisionable to a revisionable schema for entity types provided by Drupal core can be found in the following issues:
Impacts:
Site builders, administrators, editors
Module developers
Site templates, recipes and distribution developers
Comments
Change entity field type
I find it interesting that Drupal 8 supports a built-in way to change entity fields definition.
I need just that and change a integer field to a numeric field.
Does this new API supports a type change for a field with existing data (I don't think so, as the field type is not part of the field definition) ?
If not, does the following documentation uses the right process : https://www.drupal.org/node/2554097 ?
[EDIT]
I tried the following, but ends up with a Drupal\Core\Entity\EntityStorageException : Unsupported entity type