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

    <mapped-superclass name="Sylius\Component\Addressing\Model\Province" table="sylius_province">
        <unique-constraints>
            <unique-constraint columns="country_id,name" />
        </unique-constraints>

        <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="abbreviation" column="abbreviation" type="string" nullable="true" />

        <many-to-one field="country" target-entity="Sylius\Component\Addressing\Model\CountryInterface" inversed-by="provinces">
            <join-column name="country_id" referenced-column-name="id" nullable="false" />
        </many-to-one>
    </mapped-superclass>

</doctrine-mapping>
