function eck_update_8004 in Entity Construction Kit (ECK) 8
Upgrades ECK tables.
(ID columns should be of unsigned int type) and installs new definitions from code.
File
- ./
eck.install, line 61
Code
function eck_update_8004() {
$schema = Drupal::database()
->schema();
/** @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface $entityDefinitionUpdateManager */
$entityDefinitionUpdateManager = Drupal::service('entity.definition_update_manager');
$entityTypeManager = Drupal::entityTypeManager();
$eckEntityTypes = $entityTypeManager
->getStorage('eck_entity_type')
->loadMultiple();
$idColumnSpec = [
'primary key' => TRUE,
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
];
/** @var \Drupal\eck\Entity\EckEntityType $entity_type */
foreach ($eckEntityTypes as $machineName => $entity_type) {
$entityTypeDefinition = $entityTypeManager
->getDefinition($machineName);
$schema
->changeField($entityTypeDefinition
->getBaseTable(), 'id', 'id', $idColumnSpec);
$schema
->changeField($entityTypeDefinition
->getDataTable(), 'id', 'id', $idColumnSpec);
$entityDefinitionUpdateManager
->installEntityType($entityTypeDefinition);
}
}