Loading...

Migrations in Drupal 8 In this post, we will discuss the base knowledge needed to understand how migration works in Drupal 8.

Migrations in Drupal 8 follows the ETL process which stands for Extract, Transform and Load.

For the Drupal migration process, the Extract phase is called "source" and is handled by source plugins. The Transform phase is called "process", handled by process plugins, and the Load phase is called "destination" handled by destination plugins. 

The Migrate core module provides an API for migrating configuration and content to Drupal 8. 

Source plugins

The first step is to extract data from a source and return it as a set of rows. The source is typically a Drupal 6 or 7 database, but it can also be a CSV, JSON, or XML file.

Each core module implements their own source plugins that can be used to migrate content or configurations from Drupal 6 or Drupal 7 sites. For example. the source plugins for User module can be found at

core/modules/user/src/Plugin/migrate/source/

You can also create your own custom source plugins to extend core source plugins in your custom modules.

Process plugins

Each row of data provided by source plugins can be passed through one or more process plugins, which operate on the source data to transform it into the desired format. 

A list of core process plugins can be found here.

Process plugins for User core module can be found at

core/modules/user/src/Plugin/migrate/process/

Destination plugins

Destination plugins are responsible for saving new data as Drupal content (node, user, taxonomy, etc.) or configuration (content types, fields).

Destination plugins for User core module can be found at

core/modules/user/src/Plugin/migrate/destination/

Migration plugins

Migration plugin definitions are stored in a module's 'migrations' or 'migration_templates' (for backward compatibility) directory. Examples of migration plugin definitions can be found at

'core/modules/user/migrations'
In your custom module, most of the migration magic takes place in config/install/migrate_plus.* YML files where you can define Migration ID, source, process, destination, and migration_dependencies.
Useful contrib modules for migrations:
 
Migrate Plus provides extensions to core migration functionality like migration groups and usage of YML files to define migrations.
Migrate Tools provides drush commands for running and managing Drupal 8 migrations. Learn more here