Problem/Motivation

Update 8013 fails when updating from old paragraphs version (system.schema is 8011):

Failed: Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. MySQL needs the 'parent_type' field specification in order to normalize the 'paragraphs__parent_fields' index in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1607 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Proposed resolution

Add the code for updating the field storage definitions of the parent fields from paragraphs_update_8019 to paragraphs_update_8013.

CommentFileSizeAuthor
#15 paragraphs-update-error-3117998-15.patch207.39 KBBerdir
#15 paragraphs-update-error-3117998-15-test-only.patch205.77 KBBerdir
#12 paragraphs-update-error-3117998-12-interdiff.txt426 bytesBerdir
#12 paragraphs-update-error-3117998-12.patch207.61 KBBerdir
#12 paragraphs-update-error-3117998-12-test-only.patch205.98 KBBerdir
#11 paragraphs-update-error-3117998.patch207.61 KBBerdir
#11 paragraphs-update-error-3117998-test-only.patch205.99 KBBerdir
#2 3117998.patch1.63 KBvolkerk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

volkerk created an issue. See original summary.

volkerk’s picture

Status: Active » Needs review
FileSize
1.63 KB
voleger’s picture

Works for me.
Helped to perform an update from 8009 to 8023.

azovsky’s picture

Unfortunately this did not help me. Still have an error:

>  [notice] Update started: paragraphs_update_8002
>  [error]  Exception thrown while performing a schema update. MySQL needs the 'parent_id' field specification in order to normalize the 'paragraphs__parent_fields' index
>  [error]  Update failed: paragraphs_update_8002
 [error]  Update aborted by: paragraphs_update_8002
 [error]  Finished performing updates.
tamer.kamel’s picture

You need to run this drush ev "drupal_set_installed_schema_version('paragraphs', 8009)" to reset the hook update then it will work.

themic8’s picture

Thank you for the patch. This resolved my issue.

harpreet16’s picture

This works. Follow comments in https://www.drupal.org/project/paragraphs/issues/3104561#comment-13568061

Tested with:
Drupal version: 8.8.5
Initial version of paragraphs installed: 8.x-1.0.0
Updated paragraph version: 8.x-1.11
Drush Commandline Tool: 9.7.1

SerShevchyk’s picture

Drupal core 8.8.5 and Paragraphs 8.x-1.11 I still have a message The paragraph.field field needs to be updated.

Cracu’s picture

It seems that code from paragraphs_update_8010() needs to be executed again when upgrading.
To avoid any manual intervention in prod environments to reset schema for paragraphs or temporary code changes in contrib module, you could add a custom update hook for your custom profile or a custom module, then make sure that you implement hook_update_dependencies() where you enforce paragraphs_update_8017 to be executed before your custom code that re-executes code from paragraphs_update_8010().

This is a code workaround until a patch is submitted.
assuming that you have a custom profile called: my_profile, add these lines in my_profile.install

/**
 * Implements hook_update_dependencies().
 */
function my_profile_update_dependencies() {
  $dependencies['paragraphs'][8017] = array(
    'my_profile' => 8007,
  );
  return $dependencies;
}

//.......


/**
 * Re-execute code from paragraphs_update_8010() to fix errors from update hooks.
 */
function my_profile_update_8007() {
  $storage_definition = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Behavior settings'))
    ->setDescription(t('The behavior plugin settings'));
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('behavior_settings', 'paragraph', 'paragraph', $storage_definition);
}

juankvillegas’s picture

#2 worked for me.

Berdir’s picture

Sorry for the delay here. I didn't feel comfortable doing any more changes to the upgrade path without test coverage and finally managed to create an update path test, hopefully that will reduce the amount of problems like this in the future.

The last submitted patch, 12: paragraphs-update-error-3117998-12-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 12: paragraphs-update-error-3117998-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

The last submitted patch, 15: paragraphs-update-error-3117998-15-test-only.patch, failed testing. View results

  • Berdir committed 28b5fe0 on 8.x-1.x
    Issue #3117998 by Berdir, volkerk: Updating from Paragraphs 8.x-1.1 to 8...
Berdir’s picture

Status: Needs review » Fixed

Nice, so now it only fails on postgresql, which is a known issue: #3081645: make paragraphs_post_update_rebuild_parent_fields() compatible with PostGreSQL dbs

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

vertigo093i’s picture

The patch from #2 works fine for composer-based installs. The others don't because of binary patches are not supported by patch utility.