You are here

function commerce_promotion_update_8206 in Commerce Core 8.2

Ensure new field indexes on the coupon entity.

File

modules/promotion/commerce_promotion.install, line 170
Install, update and uninstall functions for the commerce_promotion module.

Code

function commerce_promotion_update_8206() {
  $entity_type_manager = \Drupal::entityTypeManager();
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();

  // Get the current coupon entity type definition, ensure the storage schema
  // class is set.
  $entity_type = $entity_type_manager
    ->getDefinition('commerce_promotion_coupon')
    ->setHandlerClass('storage_schema', CommerceContentEntityStorageSchema::class);

  // Regenerate entity type indexes.
  $definition_update_manager
    ->updateEntityType($entity_type);
}