<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="email_sms_order_queue" resource="default" engine="innodb" comment="Dotdigital Transactional SMS queue table (deprecated)">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true"
                comment="Primary key"/>
        <column xsi:type="smallint" name="website_id" unsigned="true" nullable="false" padding="5" default="0" comment="Website ID"/>
        <column xsi:type="smallint" name="store_id" unsigned="true" nullable="false" padding="5" default="0" comment="Store ID"/>
        <column xsi:type="smallint" name="type_id" unsigned="true" nullable="false" padding="5" default="0" comment="Type ID"/>
        <column xsi:type="int" name="order_id" unsigned="true" nullable="false" comment="Order ID"/>
        <column xsi:type="varchar" name="phone_number" nullable="true" length="255" comment="Phone number"/>
        <column xsi:type="varchar" name="email" nullable="true" length="255" comment="Customer email"/>
        <column xsi:type="text" name="additional_data" nullable="true" comment="Additional data"/>
        <column xsi:type="smallint" name="status" nullable="true" padding="2" comment="Status"/>
        <column xsi:type="text" name="content" nullable="true" comment="Message content"/>
        <column xsi:type="varchar" name="message_id" nullable="true" length="255" comment="Message ID"/>
        <column xsi:type="text" name="message" nullable="true" comment="Delivery message"/>
        <column xsi:type="timestamp" name="sent_at" on_update="false" nullable="true" comment="Sent at date"/>
        <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Creation time"/>
        <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Update time"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
    </table>
    <table name="email_sms_message_queue" onCreate="migrateDataFromAnotherTable(email_sms_order_queue)" resource="default" engine="innodb" comment="Dotdigital Transactional SMS queue table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true"
                comment="Primary key"/>
        <column xsi:type="smallint" name="website_id" unsigned="true" nullable="false" padding="5" default="0" comment="Website ID"/>
        <column xsi:type="smallint" name="store_id" unsigned="true" nullable="false" padding="5" default="0" comment="Store ID"/>
        <column xsi:type="smallint" name="type_id" unsigned="true" nullable="false" padding="5" default="0" comment="Type ID"/>
        <column xsi:type="int" name="order_id" unsigned="true" nullable="true" comment="Order ID"/>
        <column xsi:type="varchar" name="phone_number" nullable="true" length="255" comment="Phone number"/>
        <column xsi:type="varchar" name="email" nullable="true" length="255" comment="Customer email"/>
        <column xsi:type="text" name="additional_data" nullable="true" comment="Additional data"/>
        <column xsi:type="smallint" name="status" nullable="true" padding="2" comment="Status"/>
        <column xsi:type="text" name="content" nullable="true" comment="Message content"/>
        <column xsi:type="varchar" name="message_id" nullable="true" length="255" comment="Message ID"/>
        <column xsi:type="text" name="message" nullable="true" comment="Delivery message"/>
        <column xsi:type="timestamp" name="sent_at" on_update="false" nullable="true" comment="Sent at date"/>
        <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Creation time"/>
        <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Update time"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="EMAIL_SMS_MESSAGE_QUEUE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="email_sms_message_queue" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/>
        <constraint xsi:type="foreign" referenceId="EMAIL_SMS_MESSAGE_QUEUE_STORE_ID_STORE_STORE_ID" table="email_sms_message_queue" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
        <index referenceId="EMAIL_SMS_MESSAGE_QUEUE_WEBSITE_ID" indexType="btree">
            <column name="website_id"/>
        </index>
        <index referenceId="EMAIL_SMS_MESSAGE_QUEUE_STORE_ID" indexType="btree">
            <column name="store_id"/>
        </index>
    </table>
    <table name="email_contact">
        <column xsi:type="varchar" name="mobile_number" length="255" nullable="true" comment="Mobile number"/>
        <column xsi:type="smallint" name="sms_subscriber_status" padding="5" unsigned="true" nullable="true" identity="false" comment="SMS subscriber status"/>
        <column xsi:type="timestamp" name="sms_change_status_at" on_update="false" nullable="true" comment="SMS subscriber status last changed date"/>
        <column xsi:type="smallint" name="sms_subscriber_imported" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="SMS subscriber imported"/>
    </table>
</schema>
