<?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\Shipping\Model\ShippingMethod" table="sylius_shipping_method">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="code" column="code" type="string" unique="true" />
        <field name="configuration" column="configuration" type="json">
            <options>
                <option name="jsonb">true</option>
            </options>
        </field>

        <many-to-one field="category" target-entity="Sylius\Component\Shipping\Model\ShippingCategoryInterface">
            <join-column name="category_id" referenced-column-name="id" nullable="true" />
        </many-to-one>
        <one-to-many field="rules" target-entity="Sylius\Component\Shipping\Model\ShippingMethodRuleInterface" mapped-by="shippingMethod" orphan-removal="true">
            <cascade>
                <cascade-all />
            </cascade>
            <order-by>
                <order-by-field name="id" />
            </order-by>
        </one-to-many>

        <field name="categoryRequirement" column="category_requirement" type="integer" />
        <field name="calculator" column="calculator" type="string" />
        <field name="enabled" column="is_enabled" type="boolean" />

        <field name="position" type="integer">
            <gedmo:sortable-position />
        </field>

        <field name="archivedAt" column="archived_at" type="datetime" nullable="true" />
        <field name="createdAt" column="created_at" type="datetime">
            <gedmo:timestampable on="create"/>
        </field>
        <field name="updatedAt" column="updated_at" type="datetime" nullable="true">
            <gedmo:timestampable on="update"/>
        </field>
    </mapped-superclass>
</doctrine-mapping>
