Skip to content

Commit

Permalink
Remove data_table from existing plan_record entity type definition #829
Browse files Browse the repository at this point in the history
  • Loading branch information
paul121 committed Apr 12, 2024
1 parent e86545c commit 3b21346
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- [Remove data_table from existing plan_record entity type definition #829](https://github.com/farmOS/farmOS/pull/829)

## [3.2.1] 2024-04-12

### Fixed
Expand Down
19 changes: 19 additions & 0 deletions modules/core/plan/plan.post_update.php
Expand Up @@ -16,3 +16,22 @@ function plan_post_update_install_plan_record(&$sandbox) {
\Drupal::entityTypeManager()->getDefinition('plan_record')
);
}

/**
* Remove the plan_record data_table attribute.
*/
function plan_post_update_remove_plan_record_data_table(&$sandbox) {

// Load existing plan_record entity type and remove the data_table attribute.
$update_manager = \Drupal::entityDefinitionUpdateManager();
$plan_record = $update_manager->getEntityType('plan_record');
$plan_record->set('data_table', NULL);

// Get the existing field storage definitions. This is a required parameter
// for EntityDefinitionUpdateManagerInterface::updateFieldableEntityType.
// We cannot use EntityDefinitionUpdateManagerInterface::updateEntityType.
$field_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions('plan_record');

// Update the entity type.
$update_manager->updateFieldableEntityType($plan_record, $field_storage_definitions, $sandbox);
}

0 comments on commit 3b21346

Please sign in to comment.