Active
Project:
Drupal core
Version:
main
Component:
migration system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Jun 2021 at 13:31 UTC
Updated:
15 Sep 2025 at 14:22 UTC
Jump to comment: Most recent
I am creating migrations that use the local Drupal 8 site as the source (to convert image fields and other entities to media entities).
Accordingly, my migration's source is configured like this:
source:
# Use the site's own DB as the source.
key: default
target: default
However, when I run a migration command such as 'drush ms MYMIGRATION', I see this warning:
[error] Message: Failed to connect to your database server. The server reports the following
message: /No database connection configured for source plugin variable/.
* Is the database server running?
* Does the database exist, and have you entered the correct database name?
* Have you entered the correct username and password?
* Have you entered the correct database hostname?
This is caused by a combination of migrate's SqlBase source doing this:
protected function setUpDatabase(array $database_info) {
if (isset($database_info['key'])) {
$key = $database_info['key'];
}
else {
// If there is no explicit database configuration at all, fall back to a
// connection named 'migrate'.
$key = 'migrate';
}
and a migration probably in migrate_drupal using the Drupal\migrate_drupal\Plugin\migrate\source\Variable plugin.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
trackleft2I think this issue also affects the concept of replacing the feeds module with migrate.
Comment #4
kunalkursija commented+1 - I often get the error too during
drush ms MIGRATION_IDanddrush mim MIGRATION_ID, Interesting thing is that even with the error the data gets migrated properly.Comment #5
yivanov commentedI also confirm getting this error message while running migration from a CSV source (not even a database source). The migration itself executes correctly.
I've noticed that the Drupal\migrate\Plugin\migrate\source\SqlBase's checkRequirements() method is trying to get the migration DB connection for all migrate plugin definitions - and it happens after cache clear. I don't see any good way of handling this apart from providing fake migrate DB connection with the same credentials as the default DB just to make it suppress the error. But definitely this needs to be resolved properly.
Comment #6
kiseleva.t commentedIt seems duplicated with https://www.drupal.org/project/drupal/issues/3198339.
Issue comes from migrate_drupal_migration_plugins_alter for system_site migration and variable source plugin.
It appears on other migrations due to load definition for migration plugins (usually after cache clear).
Patch provided to that issue - error moved to logs instead of printing in Drupal messages.
Comment #7
kiseleva.t commentedComment #8
olarin commentedHaving just run into this issue myself, I'm not convinced it should be marked as a duplicate of the error reporting issue; the patch on that issue would just sort of partially hide this problem, not solve it. It doesn't seem like the entire migrate system should always expect there to be a migration database keyed as "migrate" (or if it does, then at the very least, that should be better documented somewhere - several of the migration documentation pages show examples of database connection setups with a "migrate" key, but without any indication that that key is special or can't be changed out).
Comment #11
richardhobbs commentedI get the above error message when I do a drush cr followed by drush ms if I do drush ms again there is no error message until I do another drush cr
Drupal 10.3.10
Migrate Plus 6.0.5
Migrate Tools 6.0.5
Comment #12
pfrenssenThe error is originating from
migrate_drupal_migration_plugins_alter()but should not be emitted. The code is doing a requirements check for migrating the "variables" subsystem, but this doesn't exist in Drupal 8+ since variables were replaced with config.There is similar code just above that will suppress the exception for sites running Drupal 7+ which do not meet the requirements of the D6 taxonomy vocabulary migration:
We can follow the same pattern, something like this:
Comment #15
pfrenssen