<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Advanced MSI for Magento 2
 */-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="amasty_advanced_msi_reserved_products" onCreate="migrateDataFromAnotherTableIfExists(amasty_advancedMSI_reserved_products)" resource="default" engine="innodb" comment="Reserved for shippment products">
        <column xsi:type="int" name="item_id" nullable="false" identity="true" comment="Item ID"/>
        <column xsi:type="varchar" name="sku" nullable="false" length="255" comment="Product SKU"/>
        <column xsi:type="decimal" scale="4" precision="10" name="quantity" nullable="false" comment="Product Quantity"/>
        <column xsi:type="int" name="order_id" nullable="false" comment="Order ID"/>
        <column xsi:type="varchar" name="source_code" nullable="false" length="255" comment="Source Code"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="item_id"/>
        </constraint>
    </table>

    <table name="amasty_advanced_msi_source_custom_shipping_rates" resource="default" engine="innodb" comment="Custom Shipping Rates for Source">
        <column xsi:type="int" name="source_custom_rate_id" nullable="false" identity="true" comment="Source Custom Shipping Rate ID"/>
        <column xsi:type="varchar" name="source_code" nullable="false" length="255" comment="Source Code"/>
        <column xsi:type="varchar" name="shipping_rate_code" nullable="false" length="255" comment="Shipping Rate Code"/>
        <column xsi:type="decimal" name="shipping_rate" scale="4" precision="20" unsigned="true" nullable="true" comment="Shipping Rate"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="source_custom_rate_id"/>
        </constraint>
    </table>

    <table name="amasty_advanced_msi_source_emails" resource="default" engine="innodb" comment="Emails for Source">
        <column xsi:type="int" name="source_email_id" nullable="false" identity="true" comment="Source Email ID"/>
        <column xsi:type="varchar" name="source_code" nullable="false" length="255" comment="Source Code"/>
        <column xsi:type="varchar" name="email" nullable="false" length="255" comment="Email"/>
        <column xsi:type="varchar" name="email_type" nullable="false" length="255" comment="Email Type"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="source_email_id"/>
        </constraint>
    </table>
</schema>
