How to Prevent Drush updb from Clearing Caches During Deployment
By default, the drush updb The command clears Drupal caches, which can slow down deployments and add unnecessary load. In a recent blog post, Matt Glaman shows how to override this behaviour using a custom Drush pre-command hook that automatically sets the --cache-clear flag to FALSE. This approach helps maintain performance and reduces risk in automated workflows.
The hook involves registering a method with the HookManager::PRE_COMMAND_HOOK type, targeting the UpdateDBCommands::UPDATEDB command. Within the hook, the $commandData->input()->setOption('cache-clear', FALSE); call disables the default cache clearing. While some consider this a controversial move due to the need for structured cache invalidation strategies, it’s an effective solution for teams focused on efficient, high-performance Drupal deployments—especially in CI pipelines or local development environments where speed matters.


