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

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                                      http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Sylius\Bundle\CartBundle\Entity\Cart" table="sylius_cart">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>
        <field name="locked" column="locked" type="boolean" />
        <field name="totalItems" column="total_items" type="integer" />
        <field name="total" column="total" type="decimal" precision="10" scale="2" />
        <field name="expiresAt" column="expires_at" type="datetime" />
        <one-to-many field="items" target-entity="Sylius\Bundle\CartBundle\Model\CartItemInterface" mapped-by="cart">
            <cascade>
                <cascade-all/>
            </cascade>
        </one-to-many>
    </entity>

</doctrine-mapping>

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

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                                      http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Sylius\Bundle\CartBundle\Entity\Cart" table="sylius_cart">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>
        <field name="locked" column="locked" type="boolean" />
        <field name="totalItems" column="total_items" type="integer" />
        <field name="total" column="total" type="decimal" precision="10" scale="2" />
        <field name="expiresAt" column="expires_at" type="datetime" />
        <one-to-many field="items" target-entity="Sylius\Bundle\CartBundle\Model\CartItemInterface" mapped-by="cart" orphan-removal="true">
            <cascade>
                <cascade-all/>
            </cascade>
        </one-to-many>
    </entity>

</doctrine-mapping>

Add orphan removal on default Cart -> Item relation
Add orphan removal on default Cart -> Item relation
