"Field entity definition" error when upgrading Drupal 9

Andy Wits Blog

"Field entity definition" error when upgrading Drupal 9

On the "Status Report" page of the Drupal site, I decided to clean up and remove errors. Here is one of them: ENTITY/FIELD DEFINITIONS Entity and/or field definition mismatch The following changes were detected in the entity type and field definitions. Paragraph - Field paragraph.field_dvantages_content must be updated. - Field paragraph.field_news_carousel must be updated. - Field paragraph.field_views_block_content must be updated.

Status Details

Errors Found

Entity/Field Definitions
Entity and/or Field Definition Mismatch

The following changes were found in the entity type and field definitions.

Paragraph
The paragraph.field_dvantages_content field must be updated.
The paragraph.field_news_carousel field must be updated.
The paragraph.field_views_block_content field must be updated.

It is not immediately clear how to fix this error, so I had to search the Internet again. I found out that Drupal has a module that helps solve this problem. It is called "Entity Update" and its use is associated with a certain risk. Therefore, do not forget to make a backup of the database.

So, I installed the "Entity Update" module:

composer require drupal/entity_update
drush en entity_update -y

tried to execute the command

drush upe paragraph

and got a bunch of errors when executing a query to the database:

SELECT 1 AS expression
FROM paragraph_revision__field_dvantages_content
WHERE (field_dvantages_content_target_id IS NOT NULL)
OR (field_dvantages_content_display_id IS NOT NULL)
OR (field_dvantages_content_argument IS NOT NULL)
OR (field_dvantages_content_title IS NOT NULL)
OR (field_dvantages_content_data IS NOT NULL)
LIMIT 1 OFFSET 0;

Analysis of the query and the paragraph_revision__field_dvantages_content table showed that the error is caused by 2 columns: field_dvantages_content_argument and field_dvantages_content_title, which are not in the database.

I created these 2 empty columns:

ALTER TABLE `your_drupal_db`.paragraph_revision__field_views_block_content ADD field_views_block_content_argument varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL NULL COMMENT 'argument';

ALTER TABLE `your_drupal_db`.paragraph_revision__field_views_block_content ADD field_views_block_content_title varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL NULL COMMENT 'argument';

Then we execute again:

drush upe paragraph

And we find out that the same situation is with aragraph_revision__field_news_carousel. Therefore, we also add 2 columns with _argument and _title. We do the same manipulations with paragraph_revision__field_views_block_content.

After all these requests, the error "defining the field entity" disappears.

Published on Sep 11 2023 at 12:00 am
Time to read 3 minute(s)
Categories
  • Web Development

Contact me on