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

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
    <mapped-superclass name="Sylius\Component\Promotion\Model\CatalogPromotion" table="sylius_catalog_promotion">
        <id name="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="code" unique="true" />
        <field name="name" />
        <field name="startDate" type="datetime" column="start_date" nullable="true"/>
        <field name="endDate" type="datetime" column="end_date" nullable="true"/>
        <field name="enabled" type="boolean" />
        <field name="priority" type="integer">
            <gedmo:sortable-position/>
            <options>
                <option name="default">0</option>
            </options>
        </field>
        <field name="exclusive" type="boolean">
            <options>
                <option name="default">0</option>
            </options>
        </field>
        <field name="state" column="state" />

        <one-to-many field="scopes" target-entity="Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface" mapped-by="catalogPromotion" orphan-removal="true">
            <cascade>
                <cascade-all />
            </cascade>
            <order-by>
                <order-by-field name="id" />
            </order-by>
        </one-to-many>
        <one-to-many field="actions" target-entity="Sylius\Component\Promotion\Model\CatalogPromotionActionInterface" mapped-by="catalogPromotion" orphan-removal="true">
            <cascade>
                <cascade-all />
            </cascade>
            <order-by>
                <order-by-field name="id" />
            </order-by>
        </one-to-many>
    </mapped-superclass>
</doctrine-mapping>
