Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Varbase FAQs 9.2.1 Minor update available for module varbase_faqs (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Smart SQL ID Map

2,609 sites Security covered
View on drupal.org

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.

Activity

Total releases
1
First release
Apr 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Release date
1.2.3 Stable Apr 3, 2025