public SqlContentEntityStorageSchema::requiresEntityDataMigration(EntityTypeInterface $entity_type, EntityTypeInterface $original)
Checks if existing data would be lost if the schema changes were applied.
If there are no schema changes needed, then no data needs to be migrated, but it is not the responsibility of this function to recheck what requiresEntityStorageSchemaChanges() checks. Rather, the meaning of what this function returns when requiresEntityStorageSchemaChanges() returns FALSE is undefined. Callers are expected to only call this function when requiresEntityStorageSchemaChanges() is TRUE.
This function can return FALSE if any of these conditions apply:
When this function returns FALSE, site administrators will be unable to perform an automated update, and will instead need to perform a site migration or invoke some custom update process.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The updated entity type definition.
\Drupal\Core\Entity\EntityTypeInterface $original: The original entity type definition.
bool TRUE if data migration is required, FALSE otherwise.
Overrides EntityStorageSchemaInterface::requiresEntityDataMigration
self::requiresEntityStorageSchemaChanges()
public function requiresEntityDataMigration(EntityTypeInterface $entity_type, EntityTypeInterface $original) { // If the original storage has existing entities, or it is impossible to // determine if that is the case, require entity data to be migrated. $original_storage_class = $original->getStorageClass(); if (!class_exists($original_storage_class)) { return TRUE; } // Data migration is not needed when only indexes changed, as they can be // applied if there is data. if (!$this->hasSharedTableStructureChange($entity_type, $original)) { return FALSE; } // Use the original entity type since the storage has not been updated. $original_storage = $this->entityManager->createHandlerInstance($original_storage_class, $original); return $original_storage->hasData(); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::requiresEntityDataMigration/8.1.x