<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/db_schema.xsd">
    <table name="gti_salesforce_order_queue" resource="default" engine="innodb" comment="GTI Salesforce Order Sync Queue">
        <column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
        <column xsi:type="int" name="order_id" unsigned="true" nullable="false" comment="Magento Order ID"/>
        <column xsi:type="smallint" name="status" unsigned="true" nullable="false" default="0" comment="0: Pending, 1: Synced, 2: Failed"/>
        <column xsi:type="smallint" name="attempts" unsigned="true" nullable="false" default="0" comment="Retry Attempts"/>
        <column xsi:type="text" name="error_message" nullable="true" comment="Last Error Message"/>
        <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
        <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
        <constraint xsi:type="unique" referenceId="GTI_SF_QUEUE_ORDER_ID">
            <column name="order_id"/>
        </constraint>
    </table>
    <table name="sales_order" resource="sales" engine="innodb" comment="Sales Order">
        <column xsi:type="text" name="sf_discount_breakdown" nullable="true" comment="Salesforce JSON Discount Breakdown"/>
    </table>
</schema>
