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). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). 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). 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.

This module allows you to pull data directly from any database using a custom SQL query defined in your migration configuration. The results of your query are then available for use in any process plugin or as a source for fields.

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

Activity

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

Release Timeline

Releases

Version Type Release date
8.x-1.5 Stable Jul 9, 2025
8.x-1.4 Stable Jul 8, 2025
8.x-1.x-dev Dev Jul 2, 2025