Smart SQL ID Map
This module provides an alternative ID map plugin for Drupal migrations that can handle very long plugin IDs. It is a workaround for issues where migration mapping and message table names are truncated, leading to incorrect lookups. Use this plugin when the default SQL ID map is causing problems due to table name truncation.
This module provides a work-around for #2845340: migrate mapping & messages table names are truncated, can lead to incorrect mapping lookups. It contains an id_map migration plugin which can be used even for migrations with very long plugin ID (e.g. derived migrations).
If you have a migration (plugin) thats migrate map or migrate message DB table's name is truncated, then you should use the ID map plugin smart_sql instead of the default sql one.
Fixes from 1.0.x:
- #2845340: migrate mapping & messages table names are truncated, can lead to incorrect mapping lookups
New workarounds in 1.1.x:
- #3227549: Sql id map plugin's getRowByDestination shouldn't return FALSE
- #3227660: MigrateExecutable::rollback incorrectly assumes MigrateMapInterface::getRowByDestination() returns an array with 'rollback_action' key
Usage
You only have to add this to your migration plugin:
idMap:
plugin: smart_sql
So, at the end, you should have something like this:
id: d7_tracker_settings
label: Tracker settings
migration_tags:
- Drupal 7
- Configuration
idMap:
plugin: smart_sql
source:
plugin: variable
variables_required:
- tracker_batch_size
process:
cron_index_limit: tracker_batch_size
destination:
plugin: config
config_name: tracker.settings
Replacing the Default ID Map Plugin
The easiest solution for using this ID map plugin is implementing the hook_migration_plugins_alter() hook. If your migrations are stored as Migrate Plus migration config entities, this is your only option: you cannot store this config in your migrate plus config entity's Yaml source, because Migrate Plus does not define schema for the idMap migration plugin definition config.
/**
* Implements hook_migration_plugins_alter().
*/
function custom_module_migration_plugins_alter(&$definitions) {
foreach (array_keys($definitions) as $plugin_id) {
$definitions[$plugin_id]['idMap'] = ['plugin' => 'smart_sql'];
}
}
Inspired* by Wim Leers' patch at #2845340-15: migrate mapping & messages table names are truncated, can lead to incorrect mapping lookups.
I will mark this module as obsolete when every supported Drupal 8|9 core version will contain the fix for all the issues.