<?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="facebook_sales_order" resource="sales" engine="innodb" comment="Facebook Sales Order">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
        <column xsi:type="int" name="magento_order_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Magento Order ID"/>
        <column xsi:type="varchar" name="facebook_order_id" nullable="false" length="255" comment="Facebook Order ID"/>
        <column xsi:type="varchar" name="channel" nullable="false" length="255" comment="Channel"/>
        <column xsi:type="text" name="extra_data" nullable="false" comment="Extra Data"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="FACEBOOK_SALES_ORDER_MAGENTO_ORDER_ID_SALES_ORDER_ENTITY_ID" table="facebook_sales_order" column="magento_order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/>
        <constraint xsi:type="unique" referenceId="FACEBOOK_SALES_ORDER_MAGENTO_ORDER_ID">
            <column name="magento_order_id"/>
        </constraint>
    </table>
</schema>
