I have added a product_id
column in my table vaibhav_customtabs_product_entity
. Now I am trying to add foreign key on product_id
from catalog_product_entity
->entity_id
column, but it is throwing error.
Below is my code for add foreign key.
<?php
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addForeignKey(
$installer->getFkName('vaibhav_customtabs/product_entity', 'product_id', 'catalog/product','entity_id'),
'product_id',
$installer->getTable('catalog/product'),
'entity_id',
Varien_Db_Ddl_Table::ACTION_CASCADE,
Varien_Db_Ddl_Table::ACTION_CASCADE
);
$installer->endSetup();
Error
Error in file: "/Applications/XAMPP/xamppfiles/htdocs/store1/app/code/local/Vaibhav/Customtabs/sql/vaibhav_customtabs_setup/upgrade-1.0.0.1-1.0.0.2.php" - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'store1.product_id' doesn't exist
Do I have to add foreign key or alter the column product_id
with foreign key as I have already created the column.