<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Facebook Pixel 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_fbpixel_pixels" resource="default" engine="innodb" comment="">
        <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"/>
        <column xsi:type="boolean" name="is_active" nullable="false" default="0" />
        <column xsi:type="varchar" name="pixel_id" nullable="false" length="50"/>
        <column xsi:type="boolean" name="is_category_view_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_product_view_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_initiate_checkout_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_purchase_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_search_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_add_to_cart_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_add_to_wishlist_enabled" nullable="false" default="0"/>
        <column xsi:type="boolean" name="is_registration_enabled" nullable="false" default="0"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
    </table>
    <table name="amasty_fbpixel_pixel_store" resource="default" engine="innodb" comment="">
        <column xsi:type="int" name="pixel_entity_id" padding="10" unsigned="true" nullable="false" identity="false"/>
        <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"/>
        <constraint xsi:type="foreign"
                    referenceId="amasty_fbpixel_pixel_store_store_fk"
                    table="amasty_fbpixel_pixel_store"
                    column="store_id"
                    referenceTable="store"
                    referenceColumn="store_id"
                    onDelete="CASCADE" />
        <constraint xsi:type="foreign"
                    referenceId="amasty_fbpixel_pixel_store_en_fk"
                    table="amasty_fbpixel_pixel_store"
                    column="pixel_entity_id"
                    referenceTable="amasty_fbpixel_pixels"
                    referenceColumn="entity_id"
                    onDelete="CASCADE" />
        <index referenceId="amasty_fbpixel_pixel_store_store_id_index" indexType="btree">
            <column name="store_id"/>
        </index>
        <constraint xsi:type="unique" referenceId="amasty_fbpixel_pixel_store_store_id_pixel_entity_id_index">
            <column name="pixel_entity_id"/>
            <column name="store_id"/>
        </constraint>
    </table>
</schema>
