About Drupal 8 Migrate

The migrate module has been moved into the core in Drupal 8, showing the community dedicated to making the process of upgrading between versions or migrating into Drupal easier. The migrate module takes advantage of the Drupal 8 Plugin system, offering developers with several plugin types that they can implement: MigrateProcessPlugin, MigrateSourcePlugin, and MigrateDestinationPlugin.

Quick Recap of our previous blog:

  1. Complete rewrite & moved into Drupal 8 core
  2. Out of the box support for D6 -> D8 and D7 -> D8
    • Nodes, Users, Comments, Profiles, Taxonomies
    • Content & Configuration
  3. Support for custom sources and destinations
  4. Processors for working with/manipulating data

Drupal 8 Migrate Module Overview

The Drupal 8 migrate module that is shipped with core provides a set of API’s for setting up migrations. The module also provides extensible object-oriented base classes and interfaces for migration plugins including:

  1. Source & Destination Plugins
  2. Process Plugins
  3. Config Migration Mappings

While the migrate module has been moved into core, the contributed space still provides significant value and I wouldn’t recommend trying to build a migration without it:

  1. Migrate Plus: The Migrate Plus project provides extensions to core migration framework functionality as well as examples.
  2. Migrate Tools: The Migrate Tools module provides tools for running and managing Drupal 8 migrations.

Creating Migration Mappings

In Drupal 8 all of your migration mappings are done through configuration files. In Drupal 7 these migration mappings would have been done in classes through the $this->addMapping() function.

Configuration files provide the blueprint for the migrations, and there are two main types of configuration files that we will need to define:

  1. migrate_plus.migrate_group.<name>.yml
  2. migrate_plus.migrate.<name>.yml

Migration Group

The migration group is a configuration file and is similar to the idea of hook_migrate_api in Drupal 7. This configuration file defines a group of migration classes and configures global configuration/settings to be shared across the classes.

  1. id – Unique identifier
  2. shared_configuration – Defines shared configuration between all migration classes that are part of this group. **Example: setting the source database to use
  3. dependencies – Sets the dependencies for this set of migration classes to function

Let’s see an example:

Migration Configuration File

The migration configuration file is similar to a migration class in Drupal 7. At a high level, the migration config file defines the metadata and field mappings for a particular migration in Drupal 8. There are 5 key concepts that you need to be aware of in the migration configuration file:

  1. Definition – The definition of this migration class, its dependencies, and what migration_group it belongs to
  2. Source – What migration source should be used for this migration when it is run (i.e. where am I migrating my content from?)
  3. Destination – The destination for the migration (i.e. where am I migrating my content to?)
  4. Field Mappings – The mappings from Source -> Destination
  5. Processors – The processing of the source data so that it can be consumed by the destination

Let’s see an example:

Stay tuned for our next blog post in our migration series on custom processors. In this post, we will dive into what it takes to create a custom processor for a WordPress to Drupal migration.

Would you like help to create a more detailed plan for migrating your website to Drupal 8? Contact Us – We would be happy to help!

Author 9Rooftops Health

More posts by 9Rooftops Health

Leave a Reply