function system_update_8008 in Drupal 8
Purge field schema data for uninstalled entity types.
File
- core/
modules/ system/ system.install, line 1990 - Install, update and uninstall functions for the system module.
Code
function system_update_8008() {
$entity_types = \Drupal::entityTypeManager()
->getDefinitions();
/** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $schema */
$schema = \Drupal::keyValue('entity.storage_schema.sql');
foreach ($schema
->getAll() as $key => $item) {
list($entity_type_id, , ) = explode('.', $key);
if (!isset($entity_types[$entity_type_id])) {
$schema
->delete($key);
}
}
}