<?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="codilar_whatsapp_message_types" resource="default" engine="innodb" comment="WhatsApp Message Type Tracking for SMS Fallback">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
        <column xsi:type="varchar" name="message_id" length="100" nullable="false" comment="WhatsApp Message ID"/>
        <column xsi:type="varchar" name="message_type" length="50" nullable="false" comment="Message Type (stock_alert, abandoned_cart, etc.)"/>
        <column xsi:type="varchar" name="mobile_number" length="20" nullable="false" comment="Mobile Number for SMS"/>
        <column xsi:type="text" name="text_message" nullable="false" comment="SMS Message Content"/>
        <column xsi:type="int" name="quote_id" nullable="true" comment="Quote ID for abandoned cart messages"/>
        <column xsi:type="varchar" name="customer_email" length="255" nullable="true" comment="Customer Email for abandoned cart"/>
        <column xsi:type="varchar" name="customer_name" length="255" nullable="true" comment="Customer Name for abandoned cart"/>
        <column xsi:type="varchar" name="coupon_code" length="50" nullable="true" comment="Coupon Code for abandoned cart"/>
        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
        <constraint xsi:type="unique" referenceId="CODILAR_WHATSAPP_MESSAGE_TYPES_MESSAGE_ID">
            <column name="message_id"/>
        </constraint>
        <index referenceId="CODILAR_WHATSAPP_MESSAGE_TYPES_MESSAGE_TYPE" indexType="btree">
            <column name="message_type"/>
        </index>
    </table>
</schema>
