<?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: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">
    <mapped-superclass name="Sylius\Component\User\Model\UserOAuth" table="sylius_user_oauth">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <unique-constraints>
            <unique-constraint columns="user_id,provider" name="user_provider" />
        </unique-constraints>

        <field name="provider" type="string" />
        <field name="identifier" type="string" />
        <field name="accessToken" column="access_token" type="text" nullable="true" length="8192" />
        <field name="refreshToken" column="refresh_token" type="text" nullable="true" length="8192" />

        <many-to-one field="user" target-entity="Sylius\Component\User\Model\UserInterface" inversed-by="oauthAccounts">
            <join-column name="user_id" referenced-column-name="id" />
        </many-to-one>
    </mapped-superclass>
</doctrine-mapping>
