diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 3c6fa86..82f28ab 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -134,3 +134,12 @@ function comment_update_8001() { function comment_update_8002() { // Empty update to cause a cache flush. } + +/** + * Update schema. + */ +function comment_update_8003() { + $entity_type = \Drupal::entityTypeManager()->getStorage('comment')->getEntityType(); + \Drupal::service('system.entity_schema_updater')->createTables($entity_type); + \Drupal::service('system.entity_schema_updater')->addRevisionField($entity_type); +} diff --git a/core/modules/system/src/EntitySchemaUpdater.php b/core/modules/system/src/EntitySchemaUpdater.php index e69de29..68cfcf1 100644 --- a/core/modules/system/src/EntitySchemaUpdater.php +++ b/core/modules/system/src/EntitySchemaUpdater.php @@ -0,0 +1,35 @@ +getStorage($entity_type->id()); + $database = \Drupal::database(); + $class = $entity_type_manager->getDefinition($entity_type->id())->getHandlerClass('storage_schema'); + /** @var SqlContentEntityStorageSchema $storage_schema */ + $storage_schema = new $class($entity_manager, $entity_type, $storage, $database); + $storage_schema->onEntityTypeCreate($entity_type); + } + + public function addRevisionField(EntityTypeInterface $entity_type) { + $storage_definition = BaseFieldDefinition::create('integer') + ->setLabel(new TranslatableMarkup('Revision ID')) + ->setReadOnly(TRUE) + ->setSetting('unsigned', TRUE); + \Drupal::entityDefinitionUpdateManager() + ->installFieldStorageDefinition($entity_type->getKey('revision'), $entity_type->id(), $entity_type->id(), $storage_definition); + } +} \ No newline at end of file diff --git a/core/modules/system/src/EntitySchemaUpdaterInterface.php b/core/modules/system/src/EntitySchemaUpdaterInterface.php index e69de29..65f7c23 100644 --- a/core/modules/system/src/EntitySchemaUpdaterInterface.php +++ b/core/modules/system/src/EntitySchemaUpdaterInterface.php @@ -0,0 +1,19 @@ +