<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Order Export Entity 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_order_export_attribute" resource="default" engine="innodb" comment="Amasty Order Export Attribute">
    <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
    <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="true" identity="false" default="0" comment="Attribute Id"/>
    <column xsi:type="varchar" name="attribute_code" nullable="true" length="255" comment="Attribute Code"/>
    <column xsi:type="varchar" name="frontend_label" nullable="true" length="255" comment="Frontend Label"/>
    <constraint xsi:type="primary" referenceId="PRIMARY">
      <column name="entity_id"/>
    </constraint>
    <constraint xsi:type="foreign" referenceId="AMASTY_ORDER_EXPORT_ATTR_ATTR_ID_EAV_ATTR_ATTR_ID" table="amasty_order_export_attribute" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="SET NULL"/>
    <constraint xsi:type="unique" referenceId="AMASTY_ORDER_EXPORT_ATTRIBUTE_ATTRIBUTE_ID">
      <column name="attribute_id"/>
    </constraint>
  </table>
  <table name="amasty_order_export_attribute_index" resource="default" engine="innodb" comment="Amasty Order Export Attribute Index">
    <column xsi:type="int" name="order_item_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Order Item Id"/>
    <constraint xsi:type="foreign" referenceId="FK_2C484CF23E22DAFA9A94C987C5959D16" table="amasty_order_export_attribute_index" column="order_item_id" referenceTable="sales_order_item" referenceColumn="item_id" onDelete="CASCADE"/>
    <constraint xsi:type="unique" referenceId="AMASTY_ORDER_EXPORT_ATTRIBUTE_INDEX_ORDER_ITEM_ID">
      <column name="order_item_id"/>
    </constraint>
  </table>
</schema>
