I got this error message when use migrate module
"DatabaseConnectionNotDefinedException: The specified database connection is not defined: legacy in Database::openConnection() ( (line 1675 of /public_html/includes/database/database.inc)."
What should I do?

Comments

greg__’s picture

Hey,

For those who have the same error.

It's because in your module of migration, the database connection is not set up well.
If you go to your_migration_module.module > hook_register_migrations, you will see that the $common_arguments has a 'source_connection' set to legacy.

Solution : In settings.php, create a new connection named 'legacy'.

Hope it'll help somebody.
Greg

papagrande’s picture

The error can also occur if you transfer a database that has the Acquia Commons Migration module enabled to another server that is missing the 'legacy' database connection in settings.php. Disabling 'commons_migration' is a quick fix.

chiefdigitalguy’s picture

Or in some cases you are unable to use the settings.php file you can also run Database::addConnectionInfo( ' ', ' ', array(//add db array here); from within the class file.