You are here

function system_update_8004 in Drupal 8

Add a (id, default_langcode, langcode) composite index to entities.

File

core/modules/system/system.install, line 1665
Install, update and uninstall functions for the system module.

Code

function system_update_8004() {

  // \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema was changed in
  // https://www.drupal.org/node/2261669 to include a (id, default_langcode,
  // langcode) compound index, but this update function wasn't added until
  // https://www.drupal.org/node/2542748. Regenerate the related schemas to
  // ensure they match the currently expected status.
  $manager = \Drupal::entityDefinitionUpdateManager();
  foreach (array_keys(\Drupal::entityTypeManager()
    ->getDefinitions()) as $entity_type_id) {

    // Only update the entity type if it already exists. This condition is
    // needed in case new entity types are introduced after this update.
    if ($entity_type = $manager
      ->getEntityType($entity_type_id)) {
      $manager
        ->updateEntityType($entity_type);
    }
  }
}