I am trying to add 2 FK in install schema but it returned cant add constraint. May I know why?
<?php
namespace MyModuleConnectProductSetup;
use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupSchemaSetupInterface;
use MagentoFrameworkDBDdlTable;
use phpDocumentorReflectionType;
class InstallSchema implements InstallSchemaInterface{
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$table = $setup->getConnection()->newTable(
'product_seller'
)->addColumn(
'id',
Table::TYPE_INTEGER,
null,
['identity' => true, 'nullable' => false, 'primary' => true]
)->addColumn(
'product_id',
Table::TYPE_INTEGER,
null,
['nullable' => false],
'product_id'
)->addForeignKey(
$setup->getFkName(
'product_seller',
'product_id',
'catalog_product_entity',
'entity_id'
),
'product_id',
$setup->getTable('catalog_product_entity'),
'entity_id',
Table::ACTION_CASCADE
)->addColumn(
'seller_id',
Table::TYPE_TEXT,
255,
['nullable' => false],
'seller_id'
)->addForeignKey(
$setup->getFkName(
'product_seller',
'seller_id',
'newentity_seller',
'id'
),
'seller_id',
$setup->getTable('newentity_seller'),
'seller_id',
Table::ACTION_CASCADE
)->setComment("News Table");
$setup->getConnection()->createTable($table);
$setup->endSetup();
}
}