I have several .yml files defining migrations with their corresponding source plugins. Each .yml belongs to a migration group where I defined my source as it follows:

shared_configuration:
  source:
    key: d5

Where "d5" is defined in my settings.php as it follows:

$databases['d5']['default'] = array (
		'database' => 'olddb-d5-dev',
		'username' => 'xxxx',
		'password' => 'xxxx',
		'prefix' => '',
		'host' => php_sapi_name () == 'cli' ? '127.0.0.1' : 'localhost',
		'port' => '3306',
		'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
		'driver' => 'mysql'
);

Each time I run "drush ms" I get the error "SQLSTATE[HY000] [1049] Unknown database 'olddb-prod-d6'".
This DB is an old database that I set up to try a migration using the Drupal Migrate UI but didn't work.

I tried commands like "drush config-list" to see where this info is stored and delete it but couldn't find it.
I also looked for "olddb-prod-d6" in the database and found something in the "key_value" table.

state, migrate_drupal_6, [BLOB - 293 B] //in this BLOB you can find a JSON containing info about the olddb-prod-d6 DB

I deleted that row from the DB but then I got another error:

Drupal\migrate\Plugin\migrate\source\SqlBase::setUpDatabase() must be of the type array, null given, called in XXXX\core\modules\migrate\src\Plugin\migrate\source\SqlBase.php on line 107 and defined SqlBase.php:131
...

I don't know what can be happenning...

As a workaround, I tried defining the key "migrate" in settings.php but didn't work.
Then defined the key "upgrade" and seems to work.

Nonetheless, the source key defined in the migration group is ignored by the migration.

Regards.

Comments

Eloy Ruiz created an issue. See original summary.

Eloy Ruiz’s picture

Issue summary: View changes
Eloy Ruiz’s picture

Assigned: Eloy Ruiz » Unassigned
mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

The state key you saw suggests that maybe a 'database_state_key' was being used (and is still be used, but now is referencing a non-existent key which you deleted).

I would suggest using the core configuration UI (/admin/config/development/configuration/single/export) to look at your migrations and the migration group to make sure it all makes sense - that the migrations reference the right migration group and contain no configuration (like 'database_state_key') in their source configuration, and that the referenced group contains only the shared_configuration you showed above (and, again, no 'database_state_key').

Eloy Ruiz’s picture

Hi Mike,

first of all my apologies for the long delay in answering.
After some time with the project in stand by, today I could mend the problem.

As I stated in the problem's description, I deleted the row

state, migrate_drupal_6, [BLOB - 293 B]

which lead me to another error.
The error was because there is another row in the same table with this

state, migrate.fallback_state_key, [BLOB - 24 B]

where BLOB contains info about the state to use, in this case "migrate_drupal_6".
If you reference to a state previously deleted, obviously, you get an error.

I deleted both rows and now drush ms reads correctly from the d5 database.

I hope, it can help someone.

heddn’s picture

Category: Bug report » Support request
Status: Postponed (maintainer needs more info) » Fixed

Seems fixed?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.