public function addStoreIdColumnToPositionTable(SchemaSetupInterface $setup)
    {
        $tableName = $setup->getTable('smile_virtualcategory_catalog_category_product_position');

        $setup->getConnection()->addColumn(
            $tableName,
            'store_id',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                'unsigned' => true,
                'nullable' => false,
                'default'  => 0,
                'comment'  => 'Store ID',
                'after'    => 'product_id',
            ]
        );

        $primaryKeyName = $setup->getConnection()->getPrimaryKeyName($tableName);
        // The existing primary key will be dropped.
        $setup->getConnection()->addIndex(
            $tableName,
            $primaryKeyName,
            ['category_id', 'product_id', 'store_id'],
            AdapterInterface::INDEX_TYPE_PRIMARY
        );

        $setup->getConnection()->addForeignKey(
            $setup->getFkName($tableName, 'store_id', $setup->getTable('store'), 'store_id'),
            $tableName,
            'store_id',
            $setup->getTable('store'),
            'store_id',
            \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
        );
    }
public function addStoreIdColumnToPositionTable(SchemaSetupInterface $setup)
    {
        $tableName = $setup->getTable('smile_virtualcategory_catalog_category_product_position');

        $setup->getConnection()->addColumn(
            $tableName,
            'store_id',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                'unsigned' => true,
                'nullable' => false,
                'default'  => 0,
                'comment'  => 'Store ID',
                'after'    => 'product_id',
            ]
        );

        $primaryKeyName = $setup->getConnection()->getPrimaryKeyName($tableName);
        // The existing primary key will be dropped.
        $setup->getConnection()->addIndex(
            $tableName,
            $primaryKeyName,
            ['category_id', 'product_id', 'store_id'],
            AdapterInterface::INDEX_TYPE_PRIMARY
        );

        $setup->getConnection()->addForeignKey(
            $setup->getFkName($tableName, 'store_id', $setup->getTable('store'), 'store_id'),
            $tableName,
            'store_id',
            $setup->getTable('store'),
            'store_id',
            \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
        );
    }
public function addStoreIdColumnToPositionTable ( SchemaSetupInterface $ setup ) { $ tableName = $ setup -> getTable ( 'smile_virtualcategory_catalog_category_product_position' ) ; $ setup -> getConnection ( ) -> addColumn ( $ tableName , 'store_id' , [ 'type' => \ Magento \ Framework \ DB \ Ddl \ Table :: TYPE_SMALLINT , 'unsigned' => true , 'nullable' => false , 'default' => 0 , 'comment' => 'Store ID' , 'after' => 'product_id' , ] ) ; $ primaryKeyName = $ setup -> getConnection ( ) -> getPrimaryKeyName ( $ tableName ) ; // The existing primary key will be dropped. $ setup -> getConnection ( ) -> addIndex ( $ tableName , $ primaryKeyName , [ 'category_id' , 'product_id' , 'store_id' ] , AdapterInterface :: INDEX_TYPE_PRIMARY ) ; $ setup -> getConnection ( ) -> addForeignKey ( $ setup -> getFkName ( $ tableName , 'store_id' , $ setup -> getTable ( 'store' ) , 'store_id' ) , $ tableName , 'store_id' , $ setup -> getTable ( 'store' ) , 'store_id' , \ Magento \ Framework \ DB \ Ddl \ Table :: ACTION_CASCADE ) ; }
Add 'store_id' column to 'smile_virtualcategory_catalog_category_product_position'
and make it part of the table compound primary key.

@param \Magento\Framework\Setup\SchemaSetupInterface $setup Setup interface
Add store_id column to smile_virtualcategory_catalog_category_product_position and make it part of the table compound primary key .