I have a drupal 8 site and the code is also updated to latest Drupal core 8.5.4 and also all modules are updated. I want scheduler module to be installed the on my site. So I installed the Scheduler module on my site, but when I tried to install the Scheduler module I got the error:

Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: The SQL storage cannot change the schema for an existing field (field_title in paragraph entity) with data.

.
When I debug I found in status report that there is an error for Mismatched entity and/or field definitions.
I tried to fix that bu running: drush entity-updates
But it throws the error: Mismatched entity and/or field definitions. Which means we can't update the mismatch entity, as the data exists for this field.

So in this case I need help to get rid of the Mismatch entities errors on Scheduler installation.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rahul patidar created an issue. See original summary.

jonathan1055’s picture

Hi rahul patidar,
Sorry you are getting this problem. However, I am not sure it is the fault of Scheduler. Sure, you get the error when you install Scheduler, but our code does not touch the field in question

The SQL storage cannot change the schema for an existing field (field_title in paragraph entity)

Do you have the Paragraphs module installed? The message implies that there has been an update to the Paragraph schema which has not been applied at the right time. Then after you installed Scheduler all the outstanding updates have now been run, which includes the one which causes this error. Scheduler installs cleanly in general.

The Config Update modules https://www.drupal.org/project/config_update is very good for checking discrepancies between schema and the real site config.

Jonathan

rahul patidar’s picture

Thanks Jonathan,
I've debug this and found the below code in the install file:

\Drupal::service('entity.definition_update_manager')->applyUpdates();

And this is causing the errors on module installation and uninstallation.
To fix this I have written a patch and I think it should be added in the Scheduler module as well. Please review this and include this in the Scheduler module.
Thanks!

jonathan1055’s picture

Yes that is what I was referring to. I think your error means that another module haa created an update but not executed it. Using try/catch is "defensive programming" but you are right that it could be useful. However, we are not expecting any errors at this part of the Scheduler code, so why should we necessarily add this here and not everywhere?

Are you using the Paragraphs module? It would be useful to know what exactly is causing this fault.

rahul patidar’s picture

Yes, I'm using the paragraph module and there is entity mismatch for a paragraph field, but the problem is that I have records for that field and when I tried to update the entity fields I got error that this field can not be updated as it contains data. So now I can't get the field updated and the entity mismatch issue can't be solved until I delete the data for that field, which obviously client don't want.

So in that case I had to add that patch for the module.

jonathan1055’s picture

Yes I understand your problem. But it was caused by not running the entiy updates at the right time (or maybe Paragraphs module changed their field definitions between a pre-release dev and version 1.0?) Certainly they should not change the field definitions when the module has been in use, or should provide a conversion function to retain the existing data.

I'm pleased that you found a solution for your site, but the problem is not caused by Scheduler, and could have been discovered when you installed any module which runs ->applyUpdates().

rahul patidar’s picture

Hello All,
If anyone is having issue with the entity updates and not able to update the entities, you can use 2989467-1.scheduler.try_catch_added_to_install_file.patch.
Because anyone don't want to drop the field tables or delete entities.

Sometimes it's better to adopt defensive programming, than blaming others.

jonathan1055’s picture

Category: Task » Support request
Status: Active » Closed (outdated)

Closing this now after three years.