Skip to content

Instantly share code, notes, and snippets.

@jordanlgraham
Last active March 21, 2020 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanlgraham/79f963187debb2ea66090fd87ffc15ae to your computer and use it in GitHub Desktop.
Save jordanlgraham/79f963187debb2ea66090fd87ffc15ae to your computer and use it in GitHub Desktop.
diff --git a/docroot/modules/contrib/paragraphs/paragraphs.install b/docroot/modules/contrib/paragraphs/paragraphs.install
index 1ab331447..3accef3bb 100644
--- a/docroot/modules/contrib/paragraphs/paragraphs.install
+++ b/docroot/modules/contrib/paragraphs/paragraphs.install
@@ -220,6 +220,29 @@ function paragraphs_update_8013() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$entity_type = $definition_update_manager->getEntityType('paragraph');
+ // Update the field storage definitions of the parent fields
+ // as done in 8019.
+ $last_installed_schema = \Drupal::service('entity.last_installed_schema.repository');
+ foreach (['parent_id', 'parent_type', 'parent_field_name'] as $field_name) {
+ $column_schema = [
+ 'type' => 'varchar_ascii',
+ 'length' => $field_name == 'parent_id' ? 255 : 32,
+ 'binary' => FALSE,
+ 'not null' => FALSE,
+ ];
+ // Update the field storage repository.
+ $storage_definition = $definition_update_manager->getFieldStorageDefinition($field_name, 'paragraph');
+ $storage_definition->setRevisionable(TRUE);
+ $last_installed_schema->setLastInstalledFieldStorageDefinition($storage_definition);
+
+ // Update the stored field schema.
+ // @todo: There has to be a better way to do this.
+ $key = 'paragraph.field_schema_data.' . $field_name;
+ $field_schema = \Drupal::keyValue('entity.storage_schema.sql')->get($key);
+ $field_schema['paragraphs_item_revision_field_data']['fields'][$field_name] = $column_schema;
+ \Drupal::keyValue('entity.storage_schema.sql')->set($key, $field_schema);
+ }
+
// Update the revision metadata keys to remove revision uid which is removed
// in 8017 and 8021.
if ($metadata_keys = $entity_type->get('revision_metadata_keys')) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment