Top Drupal 9 Migrate Modules được sử dụng nhiều nhất26th Jul 2022
Migration from one version of Drupal to the other version of Drupal has always been important as it helps to move with time and stay updated with the latest technology. These migrations help you ensure website safety and at the same time offer your customers an amazing experience. In this article we will help you understand migration and discuss the top modules to help with migration.
What is Drupal migrate?
According to Drupalize.me, the word "migration" is more like a generic term for any process that seeks to take data from some source external to the current Drupal site and use it to automatically create nodes, users, configuration, and any other component of your site. In short, automating what might otherwise be a tedious job of copying and pasting.
The Drupal core includes a migration system that makes it easier to import data from a variety of sources. The migrate system is a framework designed to facilitate writing custom migrations and implement this framework for Drupal-to-Drupal migrations. This system consists of three core modules: Migrate, Migrate Drupal, and Migrate Drupal UI. Here are the other Drupal 9 migration modules that can help you migrate to Drupal 9.
1. Migrate Plus
The migrate_plus project provides extensions to core migration framework functionality, as well as examples. The ongoing maintenance of this Drupal 9 migration module is handled by MTech, Virtuoso Performance, Evolving Web and DevBranch. The module is used by over 47,000 websites and was last updated on 10th March 2022
- Migration plugins can be implemented as configuration entities, allowing them to flexibly be loaded, modified, and saved.
- MigrationGroup configuration entities allow migrations to be grouped in UI and command-line tools, and also allow configuration to be shared among multiple migrations.
A PREPARE_ROW event is provided to allow object-oriented responses to the core prepare_row hook (modifying source data before processing begins).
- entity_lookup - Allows you to match source data to existing Drupal 8 entities and return their IDs (primarily for populating entity reference fields).
- entity_generate - Extends entity_lookup to actually generate an entity from the source data where one does not already exist.
- file_blob - Allows you to create a file (and corresponding file entity) from blob data.
- merge - Allows you to merge multiple source arrays into one array.
- skip_on_value - Like core's skip_on_empty, but allows you to skip either the row or process upon matching (or not) a specific value.
- str_replace - Wrapper around str_replace, str_ireplace and preg_replace.
- transliteration - process strings through the transliteration service to remove language decorations and accents. Especially helpful with file names.
Table - allows migrating data directly into a SQL table.
- SourcePluginExtension - an abstract source plugin class providing a standard mechanism for specifying a source's IDs and fields via configuration.
- Url - a source plugin supporting file- or stream-based content (where a URL, including potentially a local filepath, points to a file containing data to be migrated). The source plugin itself simply manages the (potentially multiple) source URLs, and works with fetcher plugins to retrieve the content and parser plugins to parse it (see below).
Additional plugin types
Data fetcher plugins are embedded in the Url source plugin to manage retrieval of data via a given protocol.
- File - A general-purpose fetcher for accessing any local file or stream wrapper supported by PHP's file_get_contents.
- Http - An HTTP-specific fetcher permitting usage of HTTP-specific features (such as specifying request headers).
Data parser plugins are embedded in the Url source plugin to parse the content retrieved by a fetcher.
- XML - Parses XML content using the progressive XMLReader PHP extension. Use this when XML content may be too large to be completely parsed in one go in memory.
- SimpleXML - Parses XML content using the SimpleXML PHP extension. Use this when you need full xpath support to access data elements, and the XML files are not too large.
- JSON - Parses JSON content. See this Lullabot article for an example.
- Soap - Parses SOAP feeds.
Provides authentication services to the HTTP fetcher.
- Basic - supports HTTP Basic authentication.
- Digest - supports HTTP Digest authentication.
- OAuth2 - supports OAuth2 authentication over HTTP.
Two submodules provide examples of implementing migrations.
- migrate_example - A carefully documented implementation of a custom migration scenario, designed to walk you through the basic concepts of the Drupal 8 migration framework.
- migrate_example_advanced (still in progress) - Examples of more advanced techniques for Drupal 8 migration.
- 8.x-5.x - requires Drupal 9.1+, primary development branch.
- 8.x-4.x - Compatible with Drupal 8.3.x-8.9.x, no longer supported
- 8.x-3.x - Compatible with Drupal 8.2.x only, no longer supported
- 8.x-2.0 - Compatible with Drupal 8.1.x only, no longer supported.
- 8.x-1.0 - Compatible with Drupal 8.0.x only, no longer supported.
2. Migrate Cron
The Migrate Cron module provides the functionality of executing the migrations on cronjob at a particular interval. This Drupal 9 migration module provides the UI, so each migration cron interval can be set individually. It is maintained by Eau de Web and DevBranch organizations.
- Install as you would usually install a contributed Drupal 8 module. See:
Using composer and drush
composer require drupal/migrate_cron drush en migrate_cron
After installation, set individual cron intervals by accessing /admin/config/system/migrate-cron
3. Migrate Sandbox!
Migrate Sandbox is a UI where developers can safely and quickly experiment with migrating process plugins and migrate process pipelines. You can use the sandbox to debug your custom process plugins or other contributed plugins.
This Drupal 9 migration module is an especially good tool for grokking the hard-to-grok process plugins such as sub_process, migration_lookup, entity_generate, and transpose, not to mention all the dom-related ones.
The starter config provided for each of these plugins gives you a great jumping-off point.
How the Sandbox Works
What happens in the sandbox stays in the sandbox. Here's how the magic happens.
- The sandbox migration uses a custom id_map that does not save any migrate_map data to the db.
- Instead of logging errors to the db in migrate_message tables, errors are output using on-screen messages.
- Special destination plugins migrate data into entities that are displayed in the sandbox but are never saved.
Oh, and you'll never have to reset the status of a stuck migration because the sandbox does that automatically. This all helps you fail fast while keeping your db clean.
Sandbox Escape Warnings
There are a number of process plugins from Migrate and Migrate Plus that may result in side-effects outside of the sandbox. If you include any of the following process plugins in your sandbox pipeline, there will be a warning above the Save & Run button.
- dom_migration_lookup (Migrate Plus)
- entity_generate (Migrate Plus)
- file_blob (Migrate Plus)
- service (Migrate Plus)
You may still use these plugins in Migrate Sandbox, but you should be aware that there could be persistent consequences.
What Migrate Sandbox is Not
Migrate Sandbox has limitations!
- Due to security implications, it should never be used by untrusted users.
- Migrate Sandbox is not for use on production sites for any reason.
- It is not intended to run real migrations.
- It is not designed for debugging source plugins.
- It is not designed for debugging destination plugins.
- The sandbox migration cannot be used to experiment with the track_changes setting or with high-water marks.
These three modules will help you smooth out your migration experience. Which of these have you used before and how has it helped you in your migration process?