<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Out of Stock Notification 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="product_alert_price" resource="default">
        <column xsi:type="int" name="parent_id" padding="11" unsigned="false" nullable="true" identity="false" comment="Parent Id"/>
        <column xsi:type="varchar" name="email" nullable="true" length="255" comment="Customer Email"/>
        <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_PRICE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" disabled="true"/>
        <index referenceId="PRODUCT_ALERT_PRICE_CUSTOMER_ID" disabled="true"/>
        <index referenceId="PRODUCT_ALERT_PRICE_EMAIL" indexType="btree">
            <column name="email"/>
        </index>
    </table>

    <table name="product_alert_stock" resource="default">
        <column xsi:type="int" name="parent_id" padding="11" unsigned="false" nullable="true" identity="false" comment="Parent Id"/>
        <column xsi:type="varchar" name="email" nullable="true" length="255" comment="Customer Email"/>
        <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_STOCK_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" disabled="true"/>
        <index referenceId="PRODUCT_ALERT_STOCK_CUSTOMER_ID" disabled="true"/>
        <index referenceId="PRODUCT_ALERT_STOCK_EMAIL" indexType="btree">
            <column name="email"/>
        </index>
        <index referenceId="PRODUCT_ALERT_STOCK_PARENT_ID" indexType="btree">
            <column name="parent_id"/>
        </index>
    </table>

    <table name="amasty_stock_analytics" resource="default" engine="innodb" comment="Stock Request Analytics">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
        <column xsi:type="smallint" name="subscribed" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Back in Stock Requests created"/>
        <column xsi:type="smallint" name="sent" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Back in Stock Alerts sent"/>
        <column xsi:type="decimal" name="orders" scale="4" precision="12" unsigned="false" nullable="true" comment="Revenue made from notifications sent"/>
        <column xsi:type="date" name="date" nullable="false" comment="Date collected info"/>

        <constraint xsi:type="primary" referenceId="PRIMARY">
          <column name="id"/>
        </constraint>
    </table>

    <table name="amasty_stock_analytics_temp" resource="default" engine="innodb" comment="Stock Request Analytics. Subscribed and Sent">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
        <column xsi:type="smallint" name="subscribed" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Back in Stock Requests created"/>
        <column xsi:type="smallint" name="sent" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Back in Stock Alerts sent"/>
        <column xsi:type="date" name="date" nullable="false" comment="Date collected info"/>

        <constraint xsi:type="primary" referenceId="PRIMARY">
          <column name="id"/>
        </constraint>
    </table>
</schema>
