<?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="rinnovi" resource="default" engine="innodb" comment="Subscription">
        <column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true"
                comment="entity_id"/>
        <column name="customer_id" nullable="false" xsi:type="int" comment="customer_id" unsigned="true"
                identity="false"/>
        <column name="seller_id" nullable="true" xsi:type="int" comment="seller_id" unsigned="true"
                identity="false"/>
        <column name="product_id" nullable="false" xsi:type="int" comment="product_id" unsigned="true" identity="false"/>
        <column name="active_from" nullable="true" xsi:type="datetime" comment="active_from"/>
        <column name="active_to" nullable="true" xsi:type="datetime" comment="active_to"/>
        <column name="notification_date" nullable="true" xsi:type="datetime" comment="notification"/>
        <column name="notification_number" nullable="true" xsi:type="int" comment="notification_number"/>
        <column name="status" nullable="true" xsi:type="int" comment="status" unsigned="true" identity="false"/>
        <column name="history_id" nullable="true" xsi:type="int" comment="history_id"/>
        <column name="created_at" nullable="true" xsi:type="datetime" comment="created_at"/>
        <column name="updated_at" nullable="true" xsi:type="datetime" comment="updated_at"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="FK_RINNOVI_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID"
                    table="rinnovi" column="customer_id" referenceTable="customer_entity"
                    referenceColumn="entity_id" onDelete="NO ACTION"/>
        <constraint xsi:type="foreign" referenceId="FK_RINNOVI_SELLER_ID_CUSTOMER_ENTITY_ENTITY_ID"
                    table="rinnovi" column="customer_id" referenceTable="customer_entity"
                    referenceColumn="entity_id" onDelete="NO ACTION"/>
        <constraint xsi:type="foreign" referenceId="FK_RINNOVI_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID"
                    table="rinnovi" column="product_id" referenceTable="catalog_product_entity"
                    referenceColumn="entity_id" onDelete="NO ACTION"/>
        <index referenceId="IDX_RINNOVI_CUSTOMERID" indexType="btree">
            <column name="customer_id"/>
        </index>
        <index referenceId="IDX_RINNOVI_SELLERID" indexType="btree">
            <column name="seller_id"/>
        </index>
        <index referenceId="IDX_RINNOVI_PRODUCT_ID" indexType="btree">
            <column name="product_id"/>
        </index>
        <index referenceId="IDX_RINNOVI_SUBSCRIPTION_CUSTOMER_PRODUCT" indexType="btree">
            <column name="customer_id"/>
            <column name="product_id"/>
        </index>
    </table>
    <table name="rinnovi_history" resource="default" engine="innodb" comment="rinnovi_history">
        <column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true"
                comment="entity_id"/>
        <column name="order_id" nullable="false" xsi:type="int" comment="order_id" identity="false"/>
        <column name="increment_id" nullable="true" xsi:type="varchar" comment="increment_id" length="20"/>
        <column name="order_item_id" nullable="false" xsi:type="int" comment="oder_item_id" identity="false" disabled="true"/>
        <column name="customer_id" nullable="false" xsi:type="int" comment="customer_id" identity="false"/>
        <column name="seller_id" nullable="true" xsi:type="int" comment="seller_id" identity="false"/>
        <column name="product_id" nullable="false" xsi:type="int" comment="product_id" unsigned="true"
                identity="false"/>
        <column name="is_renew" nullable="true" xsi:type="boolean" comment="is_trial"/>
        <column name="order_active_from" nullable="true" xsi:type="datetime" comment="orig_active_from"/>
        <column name="order_active_to" nullable="true" xsi:type="datetime" comment="orig_active_to"/>
        <column name="active_from" nullable="true" xsi:type="datetime" comment="active_from"/>
        <column name="active_to" nullable="true" xsi:type="datetime" comment="active_to"/>
        <column name="rinnovo_id" nullable="true" xsi:type="int" comment="rinnovo_id" identity="false"/>
        <column name="created_at" nullable="true" xsi:type="datetime" comment="created_at"/>
        <column name="updated_at" nullable="true" xsi:type="datetime" comment="updated_at"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
        <index referenceId="IDX_RINNOVI_HISTORY_ACTIVE_TO" indexType="btree">
            <column name="active_to"/>
        </index>
        <index referenceId="IDX_RINNOVI_HISTORY_CUSTOMER_ID" indexType="btree">
            <column name="customer_id"/>
        </index>
        <index referenceId="IDX_RINNOVI_HISTORY_SELLER_ID" indexType="btree">
            <column name="seller_id"/>
        </index>
        <index referenceId="IDX_RINNOVI_HISTORY_ORDER_ID" indexType="btree">
            <column name="order_id"/>
        </index>
    </table>
</schema>
