<?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" 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\User" table="sylius_user">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="username" column="username" type="string" nullable="true" />
        <field name="usernameCanonical" column="username_canonical" type="string" nullable="true" />
        <field name="enabled" column="enabled" type="boolean" nullable="false" />
        <field name="salt" column="salt" type="string" nullable="false" />
        <field name="password" column="password" type="string" nullable="true" />
        <field name="encoderName" column="encoder_name" type="string" nullable="true" />

        <field name="lastLogin" column="last_login" type="datetime" nullable="true" />
        <field name="passwordResetToken" column="password_reset_token" type="string" unique="true" nullable="true" />
        <field name="passwordRequestedAt" column="password_requested_at" type="datetime" nullable="true" />
        <field name="emailVerificationToken" column="email_verification_token" type="string" unique="true" nullable="true" />
        <field name="verifiedAt" column="verified_at" type="datetime" nullable="true" />

        <field name="locked" column="locked" type="boolean" nullable="false" />
        <field name="expiresAt" column="expires_at" type="datetime" nullable="true" />
        <field name="credentialsExpireAt" column="credentials_expire_at" type="datetime" nullable="true" />
        <field name="roles" column="roles" type="json" nullable="false">
            <options>
                <option name="jsonb">true</option>
            </options>
        </field>
        <field name="email" column="email" type="string" nullable="true" />
        <field name="emailCanonical" column="email_canonical" type="string" 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>

        <one-to-many field="oauthAccounts" target-entity="Sylius\Component\User\Model\UserOAuthInterface" mapped-by="user">
            <cascade>
                <cascade-all />
            </cascade>
            <order-by>
                <order-by-field name="id" />
            </order-by>
        </one-to-many>
    </mapped-superclass>
</doctrine-mapping>
