// Test that composite indexes are handled correctly when dropping and
// re-creating one of their columns.
$this->
addEntityIndex();
$entity_type = \Drupal::
entityTypeManager()->
getDefinition('entity_test_update'
);
$original = \Drupal::
service('entity.last_installed_schema.repository'
)->
getLastInstalledDefinition('entity_test_update'
);
\Drupal::
service('entity_type.listener'
)->
onEntityTypeUpdate($entity_type,
$original);
$storage_definition =
$this->entityDefinitionUpdateManager->
getFieldStorageDefinition('name', 'entity_test_update'
);
$this->entityDefinitionUpdateManager->
updateFieldStorageDefinition($storage_definition);
$this->
assertTrue($this->database->
schema()->
indexExists('entity_test_update', 'entity_test_update__new_index'
), 'Index created.'
);
$this->entityDefinitionUpdateManager->
uninstallFieldStorageDefinition($storage_definition);
$this->
assertFalse($this->database->
schema()->
indexExists('entity_test_update', 'entity_test_update__new_index'
), 'Index deleted.'
);
$this->entityDefinitionUpdateManager->
installFieldStorageDefinition('name', 'entity_test_update', 'entity_test',
$storage_definition);
$this->
assertTrue($this->database->
schema()->
indexExists('entity_test_update', 'entity_test_update__new_index'
), 'Index created again.'
);
} /**
* Tests creating a multi-field index when there are existing entities.
*/
public function testEntityIndexCreateWithData() { // Save an entity.
$name =
$this->
randomString();