Specifically, I am using the paragrpahs module where on fresh install of the module it will create the module related entity tables in the database. Then I export my config settings and save/commit. However, on a fresh install of my repo when I use drush config import to sync the configs, I get an error that the paragraph entity tables do not exist. I can fix this if I manually fix the database schema (drifting behind the code config) with a drupal drush entity update module. But, I dont want to have to manually check which tables are missing and manually input them. How to fix this issue? In a non drupal app I usually have a database migration tool to track all database schema changes.
You’re encountering a common issue in Drupal where configuration depends on entity storage schema that hasn’t been created yet, especially when using contributed modules like Paragraphs. Here’s a breakdown of the problem and how to fix it cleanly and automatically, without having to manually create missing tables or check for them.
Problem Summary
You install Drupal and enable the Paragraphs module.
You export config (e.g., a paragraph type called text_block).
On a fresh install, you config:import but Drupal throws an error because the paragraph tables haven’t been created yet, as they are only created when the entity type (e.g., the Paragraphs bundle) is installed via config and its schema is registered.
Root Cause
Config import happens before all entity storage schemas are created on a fresh install. Since paragraph types are config entities, their import tries to rely on storage tables that haven’t been created yet.
Best Practice Fix: Use drush deploy (with a proper deployment hook)
Instead of using drush config:import directly, do the following:
Use drush deploy, which runs:
config:import
then deploy:hook
and you can control exactly when to run things like entity:updates.
Implement a deployment hook to ensure all entity schema is up-to-date:
Create a your_module.deploy.php file in a custom module or a small “deployment” helper module.
<?php
/**
* @file
* Deployment hooks for your custom deployment process.
*/
/**
* Implements hook_post_update_NAME().
*
* Update entity schemas after config import.
*/
function your_module_post_update_update_paragraph_schema(&$sandbox = NULL) {
// This will update all entity storage schemas including Paragraphs.
\Drupal::entityDefinitionUpdateManager()->applyUpdates();
// Optionally, log that this happened.
\Drupal::logger('deploy')->notice('Applied entity schema updates (e.g., Paragraphs).');
}
Run this after config:import:
drush deploy
This ensures:
Config is imported.
Entity schemas are updated (no missing tables).
The process is repeatable and automatic.
Alternative Quick Fix (Not Recommended for Production)
If you just want a single command that updates everything and don’t need granular control, run this instead:
drush config:import -y && drush entity:updates -y
But again, drush deploy + hook_post_update` is the correct solution because it’s: