So I have started to look at the migration of a five year old Magento 1.9.0.1 to Magento 2.2 commerce site. I have to say that obtaining and setting up the data migration tool is not that difficult but getting it to do the migration is another matter.
On obtaining the tool you have to identify which version of Magento you are starting with and the version you are moving to. This is split up in the code so that you have different folders for opensource to commerce etc. And then within each of those folders is a folder named for the version you are moving from. Within that folder is a config.xml file. Which is where you define the settings for the two databases you will be using and also the location of a mapping file. There is a map.xml.dist in the same folder which you can just rename. If you are like me you will have to amend this file later on.
So you should now have the correct config.xml file to point to with your database source and destination configured. So you would think you could just run it. But no, if like me your source and destination were two distinct RDS instances you will have no luck. I could find no reason for this to fail but fail it did. So instead IO copied the two databases to my local machine and pointed my config.xml database settings to that. And then it was happy to start.
The first step when running the tool is to migrate your settings across which is fine and worked well first time. The second step is where the pain starts. The first stage in the data migration is, quite rightly, an integrity check. So this goes through and checks the tables to be migrated for foreign key errors and then checks to see what tables are in your original database that are not in your magento 2 database and have no mapping. As an aside the mapping file is setup in XML. And I have yet to really delve into that.
However, the integrity check complained about orphaned records which I cleaned up. Fairly easy. And then I hit the tables which were not going to be migrated because there was no mapping. Well in 5 years you can install a lot of plugins which can in turn create a lot of database tables. That meant that there were 239 tables in the Magento 1 database that did not have an equivalent Magento 2 table. This was in part due to the fact that we wanted to prune our use of plugins to the ones we needed and to remove some of the disused and speculative ones we had tried.
So after identifying those plugins and tables that are no longer used I could add a script to just drop those tables. Which was not so easy because a third of them had foreign keys linked to them and from them etc so I would have created orphan records. So I then added them to the map.xml file to ignore those tables. But in the XML file they are not called tables they are called documents. For reasons that I don’t care to delve into.
Ok so one more trial run of the tool and now it identified a lot of fields that were in the Magento 1 database and not in the equivalent table in the Magento 2 database. These are tables that we need to keep and the culprit is again the numerous plugins added to the original system. So the solution is again to add them to the map.xml file but this time as fields to be ignored. The map.xml file is split into sections, an area for the source database and an area for the destination database. Each of those sections has a section for fields and documents so be careful where you put your ignores or you will get an invalid XML error.
And then… Well then you run it and watch. It can take a while to complete the task and I have to say the progress bar with time remaining were totally inaccurate. But it does work and you just need to stick with it.