2

This may seem like a dumb question to some of you, I'm sure. After having worked with Drupal from version 6, I'm now for the first time using Drupal 8 and -- after some initial difficulties -- have actually come to enjoy the new development process (using Composer and Configuration Management etc.). However, I'm still failing to understand the indended workflow, after having completed a core update in my local installation. Here's my understanding, so far:

  1. In case of simpler modifications -- like, say, having created a new content type -- I usually call drush cex on my local Drupal site, then transfer the contents of the sync directory to my staging (or production, if I'm feeling venturous) site (using FTP) and go to Configuration > Development > Configuration Synchronization to apply the changes. (Note that I can't call drush cim at this point, as I'm not able to use the terminal in my staging/production site.)
  2. If any content has been created for that new content type in my local site, I transfer that content to staging using the Deploy module.

So far, that's working pretty well. However, how am I supposed to proceed, after having completed a bigger update that involves non-trivial modifications to the database?

  1. Say, I'm performing a core update: composer update drupal/core --with-dependencies
  2. I will then perform the necessary database updates locally, either by calling drush updatedb or by visiting update.php in a browser.

But then what?

Say, I'll upload all the new files via FTP to the staging site. Clearly, I cannot also copy the local database to the staging site, because the contents would be overwritten. So, I need to import the new configuration to the staging site... but accessing Configuration > Development > Configuration Synchronization to update the database will probably result in an error, exactly because the database has not been updated, yet.

This is where I'm stuck. I suspect, there's a piece to the puzzle that I'm missing, but what is it?

2

Updating Drupal 8 roughly goes like this. First in a local instance of your site:

  • Run composer update drupal/core --with-dependencies to update core. (Updating all dependencies including contrib would be composer update --with-dependencies.)
  • Now apply database updates by either drush -y updb or by visiting /update.php in your browser.
  • Next export the config that may have changed now by either drush -y cex or from your Drupal back-end in the browser.
  • Git commit and push the updated composer.lock file and the updated config files.

Next on your live site you roughly do the same, but now import the config at the end.

  • Git pull the updated composer.lock and config.
  • Run composer install --no-dev to update the files.
  • Run drush -y updb or visit /update.php to apply the database updates.
  • Run drush -y cim or visit your admin settings to import the updated config that now should match the one you exported locally earlier.

For a more advanced deployment flow, for example flushing cache and activating the maintenance mode, see my other answer on Order of drush commands for automated deployment?

| improve this answer | |
  • Thank you very much, very helpful. In all previous explanations of this process I was somehow missing the connection between updating the database and importing the configuration. The only thing I would add would be the process without using the composer on the live site, as, again, I can only use the terminal locally. So far, I have simply uploaded the updated site via FTP... is that what's intended? – Marcus C. Apr 23 at 10:44
  • 1
    @MarcusC. – FTP is not ideal, as it is a lengthy and insecure process, SFTP would be a bit better, but yeah, that's how it works when you don't have access to the command line and Composer. – leymannx Apr 23 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.