Drupal is the most popular CMS at this time at worldwide level and it is upgrading timely so we also have a large number of websites which are built in Drupal 7 version including government portals and NGOs web portal now Drupal 10 is released. The advantage of migrating to the most updated version is priceless.Community always provides us updates and works regularly to improve the open source CMS.
If you are still on Drupal 7, It's about time to migrate to Drupal 9 or 10 version. There are many factors which we need to focus on.
Drupal 7 uses an older php version less secure and Drupal 9 is using symphony oops based programming language which is more flexible and well structured.
Migration includes configuration.
Nodes, Content types, users, roles,taxonomy terms, paragraph, files types images etc..
Drupal 9 Update Checklist
We need to prepare the environment before the jump
- Upgrade to the newest PHP requirements, i.e., PHP 8.1
- Mysql version 8
Upgradings Migration steps
- The first step to be prepared for Drupal 9 Migration is detecting and removing deprecated code by using the upgrade status module.
- PHP deprecated function will also need to be change accordingly
- Cross verify the website is based on composer then we have to set the flow.
- We need to cross check the migration custom module and create it according to d9.
- Need to create all content types in drupal 9 with the same structure.
- We will do the same for taxonomy creation.
- Create users and users roles according to drupal 7.
- Adding contrib modules for d9 according to d7.
- Modules need to upgrade which is not in d7 for drupal 9.
- Webforms need to be created with the same structure.
- Custom themes will be changed according to drupal 9.
- Contrib themes will be upgraded according to D9.
Upgrade from Drupal 7 to Drupal 9
If we’re on Drupal 7, the best way is to migrate incrementally. Let’s explore the steps to transforming your site to Drupal 9:
Step 1: Firstly we have to take backup of the website first..
Step 2: Download the latest version of Drupal 9 from drupal.org. We can also use the composer for Drupal 9 installation - dependencies with Composer.
Step 3: Install & configure the Drupal 9 site on your local system as a destination site for the upgrade process.
Step 4: We have to install these necessary module ie. Migrate, Migrate plus & Migrate Drupal UI is enabled in the Drupal 9 website. Navigate through the “Extend” tab of your site and check all these modules are available in the core.
DATABASE Setup
We need both DB drupal 7 and drupal 9. Settings database connection with both like this
Migration script
We basically use the migration core module to run the script we have also another method to migrate by using excel in that case we need to add another module migrate excel
First content type migration
- In 2nd step we have to create custom module for example i create user_migration module and enable it in this module we create config folder and inside this config folder create install folder and than create two yml and also sharing naming way
- migrate_plus.migration.Unique_id.yml
- migrate_plus.migration_group.Unique_id.yml
migrate_plus.migration.Unique_id.yml this is the main file for migration. In that we map fields for example if we want to migrate content from d7 to d9
In this we work in three step source -> pipeline ->destination
Source:
- plugin: d7_node
- node_type: article
Here as you can see node_type this is basically relate to content name that we want to migrate from d7 to d9
Like
- field_d9_1 : field_d7_1
- field_body : field_body
Left side we write d9 field and right side field will be d7
User Migration
We have two method for user migration one is import from excel or we can use DB mappingIf we want to migrate user that time we will write plugin entity :user
We have tricky method to migrate all user with MD5 encrypted password in batch method
Content Migration
Basically we use two files for migration script
- Migrate_plus.migration.d7article.yml
- migrate_plus.migration_group.d7grpArticle.yml
Both files have different methods to run the script. One is for field mapping, the second one is used for the type for eg here i am taking article content type for migrating the nodes.
Everything will be the same in this file only label and id we change according to migration.
In next step explaining how we execute migration
Copy the code of migrate_plus.migration.d7article.yml and import in admin/config/development/configuration/single/import
After this we migration status by drush command
Drush ms -> for checking all migration status
Dush ms d7article -> for checking particular migration status
----------------------------- -------------- -------- ------- ---------- ------------- ---------------------
Group Migration ID Status Total Imported Unprocessed Last Imported
----------------------------- -------------- -------- ------- ---------- ------------- ---------------------
d7grpArticle d7article Idle 264 10 254 2023-03-26 17:22:42
----------------------------- -------------- -------- ------- ---------- ------------- ---------------------
This command result we see like this
Total -> Total no of rows
Imported -> How many rows migrate
Unprocessed -> How many rows left to migrate
Now we run 2nd command
Drush mim d7article (this is migrating for all rows)
Drush mim d7article mim –limit=50 (this migrating for particular no of rows)
Drush mr d7article (for rollback migrate data)
config delete
------------
config-delete migrate_plus.migration.d7speaker
Challenges : we basically check the fields if they are missing we need to rollback and import again.
FILE Migration
We have to map the data with the path to get FID drupal 7 migration script automatically migrate the file with same structure from one server to another server DB should be in same place
Its migrate all FID to map the images and document for content type its first time activity
Challenges : Sometimes we missed the FID and those file will not due to some reason either it is long or corrupted format in that case we need to check the file permission and private path setup
Its repeated and time consuming task almost 4-6 hrs took to run the script
USER MIGRATION :
This is time consuming depends upon the count of users
User email migrate with password automatically
Challenges : sometime we have to run this on batch process once 1 lac user migrate we apply date filter in core file for alteration.
Note : Before migration of nodes for any content type we have to first migrate dependent entities like taxonomy paragraph i.e. field collection we need to write an additional script file for mapping.