Run missing entity Schema updates
When you see the "Entity type needs to be updated" message on the Drupal status page, usually it's not possible to solve it without custom code.
⚠️ WARNING: Potential data loss. Use with caution.
/**
* Run missing database schema updates.
*/
function mymodule_update_10001(&$sandbox) {
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type_manager->clearCachedDefinitions();
$change_summary = \Drupal::service('entity.definition_update_manager')->getChangeSummary();
foreach ($change_summary as $entity_type_id => $change_list) {
$entity_type = $entity_type_manager->getDefinition($entity_type_id);
\Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type);
}
}
Issue:
When you see the "Entity type needs to be updated" message on the Drupal status page, usually it's not possible to solve it without custom code.
Solution:
Use this update hook in your custom module to force entity definition updates on next deployment.
Conclusion:
This is basically "drush entup", which was removed because it lead to data deletion in certain instances.
Beware:
Only use with caution and verify if this really yields the result you wanted - especially test for potential data loss.
Docs for the service if you want to know more can be found on drupal.org.
Ihre Drupal-Website zukunftssicher machen
Wir prüfen Ihr System und zeigen, was Sie für AI, Wartung und Upgrades brauchen.