<?xml version="1.0"?>
<!--
  Declarative schema for GupShup webhook logs
  Creates table: bluelogic_gupshup_webhook_log
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="bluelogic_gupshup_webhook_log" resource="default" engine="innodb"
           comment="BlueLogic GupShup Webhook Logs">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"
                comment="Entity ID"/>
        <column xsi:type="timestamp" name="received_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="false"
                comment="Received At"/>
        <column xsi:type="varchar" name="event_type" nullable="true" length="128" comment="Event Type"/>
        <column xsi:type="varchar" name="gs_id" nullable="true" length="128" comment="GupShup ID"/>
        <column xsi:type="varchar" name="message_id" nullable="true" length="128" comment="Message ID"/>
        <column xsi:type="varchar" name="status" nullable="true" length="64" comment="Status"/>
        <column xsi:type="varchar" name="recipient" nullable="true" length="64" comment="Recipient Phone Number"/>
        <column xsi:type="varchar" name="ip_address" nullable="true" length="64" comment="IP Address"/>
        <column xsi:type="text" name="payload" nullable="true" comment="Webhook Payload (JSON)"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
    </table>
    <table name="sales_order">
        <column name="wa_status" xsi:type="varchar" nullable="false" default="pending" length="20"
                comment="WhatsApp Delivery Status"/>
        <column name="whatsapp_message_id" xsi:type="varchar" nullable="true" length="255"
                comment="WhatsApp Message ID"/>
    </table>
</schema>
