<?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:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">

    <mapped-superclass name="Sylius\Component\Taxation\Model\TaxCategory" table="sylius_tax_category">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="code" column="code" type="string" unique="true" />
        <field name="name" column="name" type="string" />
        <field name="description" column="description" type="text" nullable="true" />

        <one-to-many field="rates" target-entity="Sylius\Component\Taxation\Model\TaxRateInterface" mapped-by="category">
            <cascade>
                <cascade-all/>
            </cascade>
        </one-to-many>

        <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>

<?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:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">

    <mapped-superclass name="Sylius\Component\Taxation\Model\TaxCategory" table="sylius_tax_category">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="code" column="code" type="string" unique="true" />
        <field name="name" column="name" type="string" />
        <field name="description" column="description" type="text" nullable="true" />

        <one-to-many field="rates" target-entity="Sylius\Component\Taxation\Model\TaxRateInterface" mapped-by="category"
            orphan-removal="true">
            <cascade>
                <cascade-all/>
            </cascade>
        </one-to-many>

        <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>

Make sure doctrine removes orphan tax rates, because tax rates category is not nullable.
Make sure doctrine removes orphan tax rates, because tax rates category is not nullable.
