diff --git a/core/modules/menu_link_content/menu_link_content.install b/core/modules/menu_link_content/menu_link_content.install index 8a04d02859..f5b4bbc9d2 100644 --- a/core/modules/menu_link_content/menu_link_content.install +++ b/core/modules/menu_link_content/menu_link_content.install @@ -5,6 +5,8 @@ * Install, update and uninstall functions for the menu_link_content module. */ +use Drupal\Core\Entity\Sql\SqlEntityStorageInterface; + /** * Implements hook_install(). */ @@ -42,3 +44,25 @@ function menu_link_content_update_8601() { return t('The publishing status entity key has been added to custom menu links.'); } + +/** + * Remove the bundle field. + */ +function menu_link_content_update_8800() { + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $definition_update_manager->getEntityType('menu_link_content'); + $field_storage_definition = $definition_update_manager->getFieldStorageDefinition('bundle', 'menu_link_content'); + $schema = \Drupal::database()->schema(); + + if (\Drupal::entityTypeManager()->getStorage('menu_link_content') instanceof SqlEntityStorageInterface) { + if ($schema->tableExists($entity_type->getBaseTable())) { + $schema->dropField($entity_type->getBaseTable(), 'bundle'); + } + } + + $keys = $entity_type->getKeys(); + unset($keys['bundle']); + $entity_type->set('entity_keys', $keys); + $definition_update_manager->updateEntityType($entity_type); + $definition_update_manager->uninstallFieldStorageDefinition($field_storage_definition); +}