I'm trying to use the Magento 2 migration tool to move a 1.6 site over to 2.1.4. When i get to the [stage: data migration][step: PostProcessing Step]: started step, i get this error:

[Zend_Db_Statement_Exception] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ccp.entity_id' in 'field list', query was: SELECT ccp.entity_id FROM catalog_category_product AS ccp WHERE (ccp.category_id = 1)

Looking over the M1 DB, there is no entity_id in the catalog_category_product table, so something is getting screwy (the technical term) when the migration wrap up is happening.

I have tried adding this to my map.xml file:

<ignore><field>catalog_category_product.entity_id</field></ignore>

But this error is happening much later in the process so i don't think it's a mapping issue.

This might not me related, but when i refresh the front end, i get this error:

a:4:{i:0;s:60:"Unable to load theme by specified key: 'default/{name of the old 1.6 install's theme}'";i:1;s:9773:"#0 /home/demo/public_html/oberk/vendor/magento/module-theme/Model/View/Design.php(148): Magento\Framework\View\Design\Theme\FlyweightFactory->create('default/{name of the old 1.6 install's theme}', 'frontend')

I haven't been able to track down where i need to look for a solution to the issue, since i'm not much of a sql guy.

up vote 1 down vote accepted

That's precisely your issue: there's supposed to be a entity_id field in the catalog_category_product table. Here's the code that creates it:

//From \Magento\Catalog\Setup\InstallSchema, lines 1202-1210

$table = $installer->getConnection()
    ->newTable($installer->getTable('catalog_category_product'))
    ->addColumn(
        'entity_id',
        \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
        null,
        ['identity' => true, 'nullable' => false, 'primary' => true],
        'Entity ID'
    )

The issue you need to figure out is why the entity_id column has been deleted.

  • Man, what a obvious point!!! You are right that there is a entity_id in the M2 site, but i'm looking at a bunch of M1 sites, and none of them have that column in that same table (catalog_category_product). So i'm thinking that i have something off in my mapping. Just for fun i did try adding the column into the M1 site that i'm trying to move over, but not such luck, i still get the same issue. – circlesix Feb 15 '17 at 4:20

tjons is correct in his answer, but i wanted to add some more context to the specifics of my problem and what fixed it.

It turns out that in a M1 site, there is no entity_id in the catalog_category_product table, but there is one in the default M2 site. Somehow in the creation of my M2 site that i was moving my M1 site to, that column wasn't created and therefore there was nothing to map to.

If you look in the map.xml.dist file that is used for default mapping or the map.xml that is used for custom mapping, you will see this:

<destination>
   <field_rules>
      ...
      <ignore>
         <field>catalog_category_product.entity_id</field>
      </ignore>
      ...
    </field_rules>
</destination>

Which should correctly ignore the entity_id column on the M2 site. But what the migration tool doesn't do is create the column if it's not there in the first place.

Taking a look here I found a few different ways to add this column into my M2 site. This is not advised, as it's hacking the DB directly, and for the most part isn't tested fully by me. But as i am working on a dev site that i can ruin to my hearts content, it's safe to play around with. The SQL query i ran on the M2 DB is:

ALTER TABLE `catalog_category_product` DROP PRIMARY KEY;
ALTER TABLE `catalog_category_product` ADD `entity_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

This created the column and incremented it down every row. I ran the migration tool and bam! it completed without issue.

For anyone finding this, DO NOT DO THIS ON A PRODUCTION SITE EVER! This is for dev site work only and serves as a way to get a better understanding of the error.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.