If you are getting a website upgraded from Drupal 6, 7 or transferring the data from other source, it is important to have an understanding of the migration in Drupal 8. In this blog, we have shared some of functionality of Drupal 8 migrate API for updates within the Drupal ecosystem. It will also make easier to migrate from any of the external database to Drupal.
Drupal 8 Migration
Before starting, you must know what Drupal migration is all about. Migration makes use of forming and assessing the source data and creating a fresh website that can be exported into an entirely new version of your choice by involving loads of testing.
Be it migrating or updating to a new version, Drupal’s core migration system involves the import of information from the custom sources. It also involves migrating content from the already existing versions of Drupal to Drupal 8. This means updating your website effectively from one important version to the other. Depending on the tasks you are performing, you will have to make use of the tools in varied ways.
How to Update to Drupal 8: Latest Version?
Whether you are migrating from the already existing version of Drupal, you need to install:
Migrate Module
This module offers a flexible framework for migrating content into Drupal from other sources.
Drupal Console:
Drupal Console is a tool to generate bolierplate code, interact and debug Drupal.
Migrate Plus
Migrate_Plus also features 3 modules:
It extends the core migration framework with add on features to adjust incoming source data in migration. It also code examples for making custom migration.
Migrate_Example
This module explains you the basic concepts of Drupal 8 migration framework.
Migrate_example_advanced
It features the examples of advanced techniques for Drupal 8 migration.
Configuration Update Manager
This is also an important module that needs to be installed before starting the process of migration. This module is required because the migrate API is entirely dependent on configuration files. Configuration files are the ones in which the vast majority of work is done. They are indicated as .yml
After the installation, subsequent changes to the files will not make any impact. So, you can either install or uninstall the module anytime you wish to test a configuration update. The process is slow but the drush commands used by Configuration Update Manager module can be used anytime.
Example:
If you are working on a file named migrate_plus.migration.nodes.yml and an update is made to that file to test the effect, you can run it via drush config-revert migrate_plus.migration.nodes. This imports the present state of migrate_plus.migration.nodes.yml in the database. Once you are finished with it, you can re-run the migration to test the update.
Xdebug
This module is extremely important for writing a migration. It becomes quite difficult to track issues in the migration process unless you have the potential to set breakpoints and inspect values midway via a migration process.
Also, you can save some time by running migration based on an event. This can be done using:
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
/**
* Implements hook_preprocess_page().
*/
function example_module_preprocess_page(&$vars) {
if ($qs = \Drupal::requestStack()->getCurrentRequest()->getQueryString()) {
if (strpos($qs, ‘start-migration’) !== FALSE) {
$migration_id = ‘your_migration_id’;
$migration = \Drupal::service(‘plugin.manager.migration’)->createInstance($migration_id);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable->import();
}
}
}
Drupal Migration is an Extract- Transform- Load Process
In Drupal Migrate API, the extract phase is called “source”, transform phase is called “process”, and the load phase is called “destination”.
Load means to load data to the storage. In source phase, set of data called “row” is saved from the data source. Data can easily be migrated from a database, loaded from a file or fetched from web service.
Row is sent to process phase where it is transformed as required. The transformed row is further passed to destination phase where it is saved in target Drupal website.
Migrate API Plugins
Migrate plugin specifies individual ETL migrations like node, user or taxonomy term migration. Migration plugins are defined via YAML format.
Drupal 8 migration requires a lot of work. With each passing day, there are practices that continue to evolve. You just need to be wise enough to make use of modules sensibly and make adjustments as required.
- AI’s Impact on Personalization, Analytics, and Retention in Gaming - April 12, 2024
- The Marketer’s Marathon: Long-Distance Strategies for Sustained Traffic Growth - March 29, 2024
- What Is MagSafe for iPhone? A Quick Guide - March 18, 2024