Upgrading Drupal 8 from old versions

We recently got a new Drupal 8 project that was implemented by other developers a while ago and hadn’t been maintained for months.

One of the challenges we faced was that Drupal 8 core and modules were never upgraded, and when we tried to upgrade from Drupal 8.1.0 to 8.4.3 we got a lot of errors. That led us to define a strategy to upgrade and test Drupal and modules one version at a time, by using drush and git commands.

This is the process we followed for every Drupal version upgrade:

  1. Use this website to look for Drupal 8 releases: https://www.drupal.org/project/drupal/releases
  2. Create a database backup of the stable version with drush sql-dump --result-file=<sql-file>
  3. Run the following drush command to upgrade to the next release: drush up drupal-<version>.
    For instance, to upgrade to version 8.2.0 the command should be drush up drupal-8.2.0
  4. Clear cache with drush cr
  5. Verify that website is not impacted by browsing front and back end.
  6. If upgrade was successful, add files to the git branch and commit, and proceed with point # 1 above.

This is the process we followed to revert changes, assuming that you didn’t commit changes and you are coming from point # 5 from the previous process:

  1. Remove files, which will be usually in core. I.e.: rm -rf core
  2. Recover the latest version of those files with git: git checkout -- core
  3. Run git status to check the status of the branch – hopefully at this point it will be clean, otherwise you’ll need to remove more files and recover the latest version of other files with the commands above.
  4. Run composer install in case some files generated by that command were impacted.test
  5. Import the database backup of the corresponding version: drush sql-drop -y && drush sql-query --file=<sql-file> && drush updb -y

Do you need some help?

Let's get started. Tell us a little about yourself and your organization
and we can start a conversation about your needs and our capabilities.

Related Posts