peterjaap / magerun-addons

Addon modules for n98-magerun
187 stars 41 forks source link

Recreating M2 delta migration tables does not work #64

Closed kolaente closed 4 years ago

kolaente commented 4 years ago

When trying to recreate the M2 migration tables by running 98-magerun.phar m2-migration:delta-update-changelog it fails with this error:

[Zend_Db_Statement_Exception] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'm1_database.customer_visitor' doesn't exist, query was: SELECT `customer_visitor`.`visitor_id` FROM `customer_visitor`  

[PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'm1_database.customer_visitor' doesn't exist  

It seems like the tool uses the Magento 1 db connection to query the database for magento 2 migrated data. Because the table names are different, this fails.

My workaround was to add

$m2DbObject = new \Magento_Db_Adapter_Pdo_Mysql($m2Db);
$m2DbObject->getConnection();

in https://github.com/peterjaap/magerun-addons/blob/master/src/Elgentos/Magento/Command/Migration/DeltaUpdateChangelogCommand.php#L109

This is probably not a real fix and more a workaround, but after that, it worked like a charm.

peterjaap commented 4 years ago

Yes you should add a connection to the M2 db called m2db_write in your config file.

kolaente commented 4 years ago

@peterjaap In the m1 config file?

peterjaap commented 4 years ago

@kolaente yes

kolaente commented 4 years ago

Thanks!