title: SQLSTATE[HY000]: General error: 3780 Referencing column 'store_id' and referenced column 'store_id' in foreign key constraint are incompatible
body: <p><a href="https://i.stack.imgur.com/O3tV6.png" rel="nofollow noreferrer">Table structure in phpMyAdmin</a></p>
  <p>create new table in my new module by InstallSchema facing this error when run php bin/magento setup:upgrade command  (magento 2.4)
  SQLSTATE[HY000]: General error: 3780 Referencing column 'store_id' and referenced column 'store_id' in foreign key constraint  are incompatible.</p>
  <p><a href="https://i.stack.imgur.com/qZRZB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qZRZB.png" alt="enter image description here" /></a></p>
  <pre><code>&lt;?php
  
  namespace Dealer\Sellout\Setup;
  
  use Magento\Framework\Setup\InstallSchemaInterface;
  use Magento\Framework\Setup\ModuleContextInterface;
  use Magento\Framework\Setup\SchemaSetupInterface;
  use Magento\Framework\DB\Ddl\Table;
  
  class InstallSchema implements InstallSchemaInterface
  {
      /**
       * {@inheritdoc}
       */
      public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
      {
          $setup-&gt;startSetup();
  
          /**
           * Create table 'sell-out-order'
          */
  
          $table = $setup-&gt;getConnection()-&gt;newTable(
              $setup-&gt;getTable('sell-out-order')
          )-&gt;addColumn(
              'id',
              Table::TYPE_INTEGER,
              null,
              ['identity' =&gt; true, 'nullable' =&gt; false, 'primary' =&gt; true],
              'SellOut ID'
          )-&gt;addColumn(
              'company_user_id',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Company User Id'
          )-&gt;addColumn(
              'customer_id',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Customer Id'
          )-&gt;addColumn(
              'store_id',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Store Id'
          )-&gt;addIndex(
              $setup-&gt;getIdxName('sell-out-order', ['customer_id']),
              ['customer_id']
          )-&gt;setComment(
              'Sell Outs'
          )-&gt;addForeignKey(
              $setup-&gt;getFkName('sell-out-order', 'store_id', 'store', 'store_id'),
              'store_id',
              $setup-&gt;getTable('store'),
              'store_id',
              \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
          )-&gt;addForeignKey(
              $setup-&gt;getFkName('sell-out-order', 'customer_id', 'customer_entity', 'customer_id'),
              'customer_id',
              $setup-&gt;getTable('customer_entity'),
              'customer_id',
              \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
          );
          $setup-&gt;getConnection()-&gt;createTable($table);
  
          /**
           * Create table 'sell-out-order-item'
          */
  
          $table = $setup-&gt;getConnection()-&gt;newTable(
              $setup-&gt;getTable('sell-out-order-item')
          )-&gt;addColumn(
              'id',
              Table::TYPE_INTEGER,
              null,
              ['identity' =&gt; true, 'nullable' =&gt; false, 'primary' =&gt; true],
              'SellOut Order Item ID'
          )-&gt;addColumn(
              'sell-out-order_id',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'SellOut Order Id'
          )-&gt;addColumn(
              'product_id',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Product Id'
          )-&gt;addColumn(
              'name',
              Table::TYPE_TEXT,
              255,
              ['nullable' =&gt; false],
              'Product SKU'
          )-&gt;addColumn(
              'product_type',
              Table::TYPE_TEXT,
              255,
              ['nullable' =&gt; false],
              'Product SKU'
          )-&gt;addColumn(
              'sku',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Product SKU'
          )-&gt;addColumn(
              'qty',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Qty'
          )-&gt;addColumn(
              'store_id',
              Table::TYPE_INTEGER,
              255,
              ['nullable' =&gt; false],
              'Store Id'
          )-&gt;addIndex(
              $setup-&gt;getIdxName('sell-out-order-item', ['sku']),
              ['sku']
          )-&gt;setComment(
              'Sell Out Items'
          )-&gt;addForeignKey(
              $setup-&gt;getFkName('sell-out-order-item', 'store_id', 'store', 'store_id'),
              'store_id',
              $setup-&gt;getTable('store'),
              'store_id',
              \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
          )-&gt;addForeignKey(
              $setup-&gt;getFkName('sell-out-order-item', 'sell-out-order_id', 'sell-out-order', 'sell-out-order_id'),
              'sell-out-order_id',
              $setup-&gt;getTable('sell-out-order'),
              'sell-out-order_id',
              \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
          );
          $setup-&gt;getConnection()-&gt;createTable($table);
          $setup-&gt;endSetup();
      }
  }
  </code></pre>