<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Promo Banners Base for Magento 2
 */-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
  <table name="amasty_banner_rule" resource="default" engine="innodb" comment="amasty_banner_rule">
    <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Id"/>
    <column xsi:type="varchar" name="rule_name" nullable="false" length="255" default="" comment="Rule Name"/>
    <column xsi:type="int" name="is_active" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Is Active"/>
    <column xsi:type="int" name="sort_order" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Sort order"/>
    <column xsi:type="datetime" name="from_date" on_update="false" nullable="true" comment="From Date"/>
    <column xsi:type="datetime" name="to_date" on_update="false" nullable="true" comment="To Date"/>
    <column xsi:type="varchar" name="stores" nullable="false" length="255" default="" comment="Stores"/>
    <column xsi:type="varchar" name="cust_groups" nullable="false" length="255" default="" comment="Customer Groups"/>
    <column xsi:type="varchar" name="banner_position" nullable="true" length="255" comment="Banner Position"/>
    <column xsi:type="varchar" name="banner_img" nullable="false" length="255" default="" comment="Banner Image"/>
    <column xsi:type="varchar" name="banner_link" nullable="false" length="255" default="" comment="Banner Link"/>
    <column xsi:type="varchar" name="banner_title" nullable="false" length="255" default="" comment="Banner Title"/>
    <column xsi:type="varchar" name="cms_block" nullable="false" length="255" default="" comment="CMS Block"/>
    <column xsi:type="text" name="conditions_serialized" nullable="true" comment="Conditions Serialized"/>
    <column xsi:type="text" name="cats" nullable="false" comment="Cats"/>
    <column xsi:type="text" name="show_on_products" nullable="true" comment="Show On Products"/>
    <column xsi:type="varchar" name="banner_type" nullable="false" length="16" default="image" comment="0 - image, 1 - cms block, 2 - html page, 3 - products"/>
    <column xsi:type="text" name="html_text" nullable="true" comment="HTML Text"/>
    <column xsi:type="int" name="show_products" padding="11" unsigned="false" nullable="true" identity="false" default="0" comment="Show Products"/>
    <column xsi:type="text" name="actions_serialized" nullable="true" comment="Actions_serialized"/>
    <column xsi:type="text" name="show_on_search" nullable="true" comment="Show On Search"/>
    <column xsi:type="smallint" name="after_n_product_row" padding="6" unsigned="false" nullable="true" identity="false" comment="Show Banner After N Products Row"/>
    <column xsi:type="smallint" name="n_product_width" padding="6" unsigned="false" nullable="true" identity="false" comment="N Product Width"/>
    <column xsi:type="text" name="segments" nullable="true" comment="Segments"/>
    <constraint xsi:type="primary" referenceId="PRIMARY">
      <column name="id"/>
    </constraint>
  </table>
  <table name="amasty_banner_attribute" resource="default" engine="innodb" comment="amasty_banner_attribute">
    <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Id"/>
    <column xsi:type="int" name="rule_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Rule Id"/>
    <column xsi:type="varchar" name="code" nullable="false" length="255" default="" comment="Code"/>
    <constraint xsi:type="primary" referenceId="PRIMARY">
      <column name="id"/>
    </constraint>
    <constraint xsi:type="foreign" referenceId="AMASTY_BANNER_RULE_RULE_ID_AMASTY_BANNER_ATTRIBUTE_ID" table="amasty_banner_attribute" column="rule_id" referenceTable="amasty_banner_rule" referenceColumn="id" onDelete="CASCADE"/>
  </table>
  <table name="amasty_banner_rule_products" resource="default" engine="innodb" comment="amasty_banner_rule_products">
    <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Id"/>
    <column xsi:type="int" name="rule_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Rule Id"/>
    <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Rule Id"/>
    <constraint xsi:type="primary" referenceId="PRIMARY">
      <column name="id"/>
    </constraint>
  </table>
</schema>
