Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

smart_sql_idmap

2,568 sites Security covered
View on drupal.org

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.

Activity

Total releases
1
First release
Apr 2025
Latest release
1 year ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.2.3 Stable Apr 3, 2025