Magento 2 – Fix Data Migration SQL Error ‘Column Not Found’

databasefatal errormagento2magento2-migration-tool

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.

Best Answer

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.

Related Topic