<?xml version="1.0" encoding="UTF-8"?>

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="sales_order_grid" resource="default" engine="innodb">
        <column xsi:type="int" name="integration_order_id" nullable="true" 
            comment="Source Order Id"/>
    </table>
    <table  name="sales_order" resource="default" engine="innodb">
        <column xsi:type="int" name="integration_order_id" nullable="true"
                comment="Source Order Id"/>
    </table>
    <table name="productdesigner_api_module" resource="default" engine="innodb" comment="Product Designer APi module Table">
        <column xsi:type="int" name="id" padding="11" unsigned="true" nullable="false" identity="true"
                comment="Primary Key of productdesigner_api_module table"/>
        <column xsi:type="varchar" name="name" default="null" nullable="false" length="255" comment="Api Module name"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
    </table>
    <table name="productdesigner_api_request_response_log" resource="default" engine="innodb" comment="Product Designer APi Request Response log Table">
        <column xsi:type="int" name="id" padding="11" unsigned="true" nullable="false" identity="true"
                comment="Primary Key of productdesigner_api_request_response_log table"/>
        <column xsi:type="int" name="module_id" nullable="false" unsigned="true" comment="Api Module name"/>
        <column xsi:type="varchar" name="module_action" nullable="false" length="100" default="null"  comment="Api Module Action (1:Create 2:Delete)"/>
        <column xsi:type="varchar" name="response_type" nullable="false" length="100" default="null" comment="Api Module Action 0:Error, 1: Success, 2: Partial,"/>
        <column xsi:type="mediumtext" name="request_json"  nullable="false"   comment="Api Json Request" />
        <column xsi:type="mediumtext" name="response_json"  nullable="false"  comment="Api Json Resonse" />
        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Created At"/>
        <column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Updated At"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="FOREIGN" table="productdesigner_api_request_response_log" column="module_id" referenceTable="productdesigner_api_module" referenceColumn="id" onDelete="CASCADE"/>
    </table>
    <table name="productdesigner_api_variation_importer" resource="default" engine="innodb">
        <column xsi:type="int" name="id" padding="11" unsigned="true" nullable="false" identity="true"/>
        <column xsi:type="int" name="product_variation_id" nullable="false" unsigned="true"/>
        <column xsi:type="int" name="source_product_id" nullable="false" unsigned="true"/>
        <column xsi:type="text" name="request_json" nullable="true" />
        <column xsi:type="smallint" name="status" padding="6" nullable="true" default="0" />
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="FOREIGN" table="productdesigner_api_variation_importer" column="product_variation_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
    </table>
</schema>