Prerequisites:
Existing database entered in the settings.php file.
In this example:

$databases['mg_legacy']['default'] = array (
 'database' => 'mg_legacy',
 'username' => 'xxx',
 'password' => 'xxx',
 'host' => 'localhost',
 'port' => '3306',
 'driver' => 'mysql',
 'prefix' => '',
 'collation' => 'utf8mb4_general_ci',
);

Installation:
Enable module

Description:
With this CustomSQLQuery plugin you can enter a custom SQL string in your migration config file and it will pull the data directly from any database.

It returns all the fields queried in the SQL string in the row object. So any field you select in the SQL query can be accessed by any process plugin or as a source for any field.

IMPORTANT: Any changes to the sql requires you to re-install your custom migration module for the settings to take affect. You can do so with

drush pmu [module_name] -y && drush en [module_name] -y

Please see config below as an example:

id: resources
label: Resources
migration_group: mmg8_legacy_migrations
migration_dependencies:
 required:
 - mmg8_legacy_migrations_article_type
source:
 plugin: custom_sql_query
 key: mg_legacy
 keys:
 - id
 sql_query: 'SELECT resources.id,
 CONCAT(''/'', resources.slug) as slug,
 resources.title,
 resources.description,
 resources.file,
 resources.published,
 resources.category_id,
 resources.created_at,
 resources.updated_at,
 resources.locked,
 resources.subtitle,
 resources.archive
 FROM resources resources'
destination:
 plugin: entity:node
 default_bundle: article
process:
 title: title
 path/pathauto:
 plugin: default_value
 default_value: 0 # Disable pathauto.
 path/alias: slug
Supporting organizations:
Work time

Project information

Releases

8.x-1.5 Stable release covered by the Drupal Security Team released 9 July 2025
Works with Drupal: ^8 || ^9 || ^10 || ^11

Fixes a bug introduced in 1.4

Install:

Development version: 8.x-1.x-dev updated 16 Jun 2026 at 12:08 UTC