Skip to content

Removing: Magento 2 Data Migration Tables – The Client Chose OpenMage Instead

Around a year ago, a client considered moving to Magento 2 and at the advice of another developer, they installed the data-migration-tool to prepare for a migration to Magento 2.

However, they realized the (unnecessary) cost of re-writing all their extensions and they have since made the decision to stick in the v1 universe and migrate (or upgrade) to OpenMage.

However, the data-migration-tool has done a few things they didn’t know would happen.

It has created a m2_cl_ table for nearly every table in the database.

mysql> show tables;
+----------------------------------------------------------+
| Tables                                                   |
+----------------------------------------------------------+
| m2_cl_customer_entity                                    |
| ....                                                     |
+----------------------------------------------------------+
651 rows in set (0.02 sec)

On the surface, this doesn’t appear to be a major problem. However, they now have a replica of almost every table in their database – and the data is also duplicated.

To add to this… Each of these tables appears to have a corresponding trigger.

mysql> SHOW TRIGGERS FROM `__` WHERE `table` = "customer_entity";
+----------------------------------+--------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| Trigger                          | Event  | Table           | Statement                                                                                                                                                   | Timing |
+----------------------------------+--------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| trg_customer_entity_after_insert | INSERT | customer_entity | BEGIN INSERT IGNORE INTO m2_cl_customer_entity (`entity_id`, `operation`) VALUES (NEW.entity_id, 'INSERT')ON DUPLICATE KEY UPDATE operation = 'INSERT'; END | AFTER  |
| trg_customer_entity_after_update | UPDATE | customer_entity | BEGIN INSERT IGNORE INTO m2_cl_customer_entity (`entity_id`, `operation`) VALUES (NEW.entity_id, 'UPDATE')ON DUPLICATE KEY UPDATE operation = 'UPDATE'; END | AFTER  |
| trg_customer_entity_after_delete | DELETE | customer_entity | BEGIN INSERT IGNORE INTO m2_cl_customer_entity (`entity_id`, `operation`) VALUES (OLD.entity_id, 'DELETE')ON DUPLICATE KEY UPDATE operation = 'DELETE'; END | AFTER  |
+----------------------------------+--------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+

This makes their DB twice the size it should be, and then the triggers put unnecessary extra load on the DB.

Does anyone have a quick way to remove all these tables and triggers?