<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) 2023 Amasty (https://www.amasty.com)
 * @package Visual Merchandiser Core by Amasty for Magento 2 (System)
 */-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="amasty_merchandiser_product_index_eav" resource="default" engine="innodb"
            comment="Amasty Product EAV Index Table For Merchandiser">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Entity ID"/>
        <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Attribute ID"/>
        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
        <column xsi:type="mediumtext" name="value" nullable="false" comment="Value"/>
        <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Source Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
            <column name="attribute_id"/>
            <column name="store_id"/>
            <column name="source_id"/>
        </constraint>
        <index referenceId="AMASTY_MERCHANDISER_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree">
            <column name="attribute_id"/>
        </index>
        <index referenceId="AMASTY_MERCHANDISER_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree">
            <column name="store_id"/>
        </index>
    </table>
    <table name="amasty_merchandiser_product_index_eav_replica" resource="default" engine="innodb"
            comment="Amasty Product EAV Index Table For Merchandiser">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Entity ID"/>
        <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Attribute ID"/>
        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
        <column xsi:type="mediumtext" name="value" nullable="false" comment="Value"/>
        <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Source Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
            <column name="attribute_id"/>
            <column name="store_id"/>
            <column name="source_id"/>
        </constraint>
        <index referenceId="AMASTY_MERCHANDISER_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree">
            <column name="attribute_id"/>
        </index>
        <index referenceId="AMASTY_MERCHANDISER_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree">
            <column name="store_id"/>
        </index>
    </table>
    <table name="amasty_merchandiser_product_index_eav_tmp" resource="default" engine="innodb"
            comment="Amasty Product EAV Index Table For Merchandiser">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Entity ID"/>
        <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Attribute ID"/>
        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
        <column xsi:type="mediumtext" name="value" nullable="false" comment="Value"/>
        <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Source Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
            <column name="attribute_id"/>
            <column name="store_id"/>
            <column name="source_id"/>
        </constraint>
        <index referenceId="AMASTY_MERCHANDISER_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree">
            <column name="attribute_id"/>
        </index>
        <index referenceId="AMASTY_MERCHANDISER_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree">
            <column name="store_id"/>
        </index>
    </table>
    <table name="amasty_merchandiser_visible_product" resource="default" engine="innodb"
            comment="Amasty Visible Product Index Table For Merchandiser">
        <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" identity="false"
                  comment="Product ID"/>
        <column xsi:type="int" name="store_id" padding="10" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="product_id"/>
            <column name="store_id"/>
        </constraint>
    </table>
    <table name="amasty_merchandiser_visible_product_replica" resource="default" engine="innodb"
            comment="Amasty Visible Product Index Table For Merchandiser">
        <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" identity="false"
                  comment="Product ID"/>
        <column xsi:type="int" name="store_id" padding="10" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="product_id"/>
            <column name="store_id"/>
        </constraint>
    </table>

    <table name="amasty_merchandiser_visible_product_tmp" resource="default" engine="innodb"
            comment="Amasty Visible Product Index Table For Merchandiser">
        <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" identity="false"
                  comment="Product ID"/>
        <column xsi:type="int" name="store_id" padding="10" unsigned="true" nullable="false" identity="false"
                  comment="Store ID"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="product_id"/>
            <column name="store_id"/>
        </constraint>
    </table>
</schema>
