I have a live site which runs on drupal 8. I am using drush 8.5.3 with the installation. Whenever I run drush updb the site automatically goes to maintenance mode. Is there a way to do this without going to maintenance mode. In simple words, can I use drush updb with my site running?
-
1Consider the answer found here: drupal.stackexchange.com/questions/270793/…– 100picCommented Jun 5, 2019 at 7:40
-
1Possible duplicate of Should a site be in maintenance mode when running the Drush Up command?– leymannxCommented Jun 5, 2019 at 9:22
-
I have experienced issues with this causing which is possibly an edge case. In a containerized infrastructure sometime the container terminates (or there is a system failure) . This makes the site stuck in maintenance mode even after subsequent successful updbs. The onlyway to get out of it manually via the UI or drush.– awmCommented Jun 23, 2020 at 19:26
2 Answers
Actually, if you take a look at the drush code for updatedb command, you can find this piece of code in updateBatch() function:
$original_maint_mode = \Drupal::service('state')->get('system.maintenance_mode');
if (!$original_maint_mode) {
\Drupal::service('state')->set('system.maintenance_mode', true);
$operations[] = ['\Drush\Commands\core\UpdateDBCommands::restoreMaintMode', [false]];
}
For safety reasons, the drush command puts your site in maintenance mode during the update and then set it back online once it is completed. It prevents your users from accessing the website and generate possible conflicts within the database while it is updating.
There is a pretty clear explanation of this here
If you really wish to avoid the maintenance mode, though, you could run update.php
directly from your website.
No. The critical path for drush updb
is through:
Where drush_update_batch()
toggles the maintenance mode state prior to processing the updates needed to be processed.
Theoretically, you could modify Drush itself or create your own Drush command that mimics the drush_update_batch()
code without toggling maintenance mode. But a better question would be why? Maintenance mode is being set to prevent any problems while DB schema is being altered.