<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="catalog_eav_attribute" resource="default" comment="Catalog EAV Attribute Table">
        <column xsi:type="text" name="additional_data" nullable="true" comment="Additional swatch attributes data"/>
    </table>
    <table name="eav_attribute_option_swatch" resource="default" engine="innodb" comment="Magento Swatches table">
        <column xsi:type="int" name="swatch_id" padding="10" unsigned="true" nullable="false" identity="true"
                comment="Swatch ID"/>
        <column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
                comment="Option ID"/>
        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
        <column xsi:type="smallint" name="type" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Swatch type: 0 - text, 1 - visual color, 2 - visual image"/>
        <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Swatch Value"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="swatch_id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_OPTION_SWATCH_STORE_ID_STORE_STORE_ID"
                    table="eav_attribute_option_swatch" column="store_id" referenceTable="store"
                    referenceColumn="store_id" onDelete="CASCADE"/>
        <constraint xsi:type="foreign" referenceId="EAV_ATTR_OPT_SWATCH_OPT_ID_EAV_ATTR_OPT_OPT_ID"
                    table="eav_attribute_option_swatch" column="option_id" referenceTable="eav_attribute_option"
                    referenceColumn="option_id" onDelete="CASCADE"/>
        <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_OPTION_SWATCH_STORE_ID_OPTION_ID">
            <column name="store_id"/>
            <column name="option_id"/>
        </constraint>
        <index referenceId="EAV_ATTRIBUTE_OPTION_SWATCH_SWATCH_ID" indexType="btree">
            <column name="swatch_id"/>
        </index>
    </table>
</schema>