How to successfully migrate from one Drupal version to another

Migrating to a new version of Drupal can be a complex and daunting undertaking, yet it's essential to keeping your website up-to-date and secure. In this article, we'll guide you through the different steps for each version to ensure a smooth transition.

Preparing for migration: best practices to know

What volume of data are we talking about?

If the volume is relatively low, it may be simpler to consider a re-entry directly into the back-office of the later version or a few copy-pastes. You can decide on the number of days required. If you can move the data in 2 or 3 days, that's obviously more interesting than 4 days of development.

Preparing your migration file

Analyze your original data file to identify the key information to be migrated. Evaluate the data to be migrated in terms of relevance, quality and volume. It may be useful to create a detailed migration plan to identify the data you wish to migrate first. This file should contain: an id (mandatory) to identify the migration, a label, but also one or more tags, dependencies to order the execution of linked migrations.

Check the quality of your data

Before migrating, it's important to clean up and normalize your data to ensure consistency. Also make sure they conform to the standards of the new Drupal version, for example, date formats and field types.

Installing the Drupal 8 Upgrade Status module : the right idea

Drupal 8 Upgrade Status is a module for Drupal 8 that helps migrate to Drupal 9. It provides a detailed compatibility analysis of the code in use. It analyzes them to identify elements that need to be updated before migration.

Drupal 8 Upgrade Status then generates detailed compatibility reports on the modules, themes and third-party libraries used on your Drupal 8 project, indicating whether they are compatible with Drupal 9 or require updating. These reports include clear instructions on which versions are compatible with Drupal 9, as well as instructions on how to install and configure them.

Bref. Drupal 8 Upgrade Status is an asset to have up your sleeve before you start migrating.

Check the compatibility of custom developments

Do you have custom code within your project? To make sure it's compatible with Drupal 9, you can use code analysis tools such as PHP_CodeSniffer or PHPMD to help you identify potential problems. Then remember to run tests to ensure that all functionality works properly after migration.

Updating versions in the composer. json file

To update versions of modules and dependencies in the composer.json file.json

To update the versions of modules and dependencies in the composer.json file from Drupal 8 to Drupal 9, you can use the required composer command followed by the name of the module and the required version.

For example, to update the "views" module, you can use the drupal/views:^9.0 command. Then run the command compose update.

The different ways to migrate

Before migrating, it's important to back up all your site files and data. You can then, proceed in 3 different ways:

Manual migration: this method involves manually downloading the latest version of Drupal 9 and copying the files and data from the Drupal 8 site to the new one. This method is best suited to small, simple sites.

Migration with the web interface: Drupal 9 offers a migration interface that lets you import data, modules and themes. All you have to do is let yourself be guided. This method is best suited to medium-sized sites.

Finally, command-line migration from Drupal 8 to Drupal 9 involves using the drush command. Here are the steps to follow: make sure your server meets the prerequisites for the higher version and install Drush.

Download Drupal 9 and unzip it into a folder on your server. Run the compose install command in the folder to install all the required dependencies. Run the drush migrate-upgrade command to start migrating from Drupal 8 to Drupal 9. This method obviously requires the most technical expertise. It should therefore be reserved for experienced users. Once you've done this, always carry out thorough tests to make sure everything's working properly.

Use tools for data migration

These tools enable developers to move data safely and efficiently. Among these tools, Migrate Plus provides additional features, such as data import plugins, configuration files and migration process definitions.

Migrate Tools, meanwhile, provides a set of practical tools for setting up, deleting and running migrations or handling error messages. Finally, Migrate Upgrade provides a graphical interface for migration.