<?xml version="1.0"?>
<!--
/**
 * @license http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @author Benjamin Houillon <bhouillon@kaliop.com>
 * @copyright Copyright (c) 2019 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com/)
 */
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="kp_top_banner" resource="default" engine="innodb" comment="KP Top Banner Table">
        <column xsi:type="smallint" name="top_banner_id" padding="6" unsigned="false" nullable="false" identity="true"
                comment="Entity ID"/>
        <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
                default="1" comment="Is Top Banner Active"/>
        <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Top Banner Title"/>
        <column xsi:type="mediumtext" name="content" nullable="true" comment="Top Banner Content"/>
        <column xsi:type="timestamp" name="creation_time" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Top Banner Creation Time"/>
        <column xsi:type="timestamp" name="update_time" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
                comment="Top Banner Modification Time"/>
        <column xsi:type="date" name="from_date" nullable="true"
                comment="Top Banner From Date"/>
        <column xsi:type="date" name="to_date" nullable="true"
                comment="Top Banner To Date"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="top_banner_id"/>
        </constraint>
        <index referenceId="KP_TOP_BANNER_TOP_BANNER_ID" indexType="btree">
            <column name="top_banner_id"/>
        </index>
    </table>
    <table name="kp_top_banner_store" resource="default" engine="innodb" comment="KP Top Banner To Store Linkage Table">
        <column xsi:type="smallint" name="top_banner_id" padding="6" unsigned="false" nullable="false" identity="false"/>
        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
                comment="Store ID"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="top_banner_id"/>
            <column name="store_id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="KP_TOP_BANNER_STORE_TOP_BANNER_ID_KP_TOP_BANNER_TOP_BANNER_ID" table="kp_top_banner_store"
                    column="top_banner_id" referenceTable="kp_top_banner" referenceColumn="top_banner_id" onDelete="CASCADE"/>
        <constraint xsi:type="foreign" referenceId="KP_TOP_BANNER_STORE_STORE_ID_STORE_STORE_ID" table="kp_top_banner_store"
                    column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
        <index referenceId="KP_TOP_BANNER_STORE_STORE_ID" indexType="btree">
            <column name="store_id"/>
        </index>
    </table>
</schema>
