<?xml version="1.0" encoding="UTF-8"?>
<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
                          https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity
            name="Basango\FeedManagement\Domain\Model\Entity\Bookmark"
            repository-class="Basango\IdentityAndAccess\Infrastructure\Persistence\Doctrine\ORM\BookmarkOrmRepository"
            table="bookmark"
    >
        <id name="id" type="bookmark_id">
            <generator strategy="NONE"/>
        </id>

        <many-to-one field="user" target-entity="Basango\IdentityAndAccess\Domain\Model\Entity\User" fetch="EAGER">
            <join-column nullable="false" on-delete="CASCADE" />
        </many-to-one>

        <field name="name" length="255" />
        <field name="description" length="512" nullable="true" />
        <field name="isPublic" type="boolean">
            <options>
                <option name="default">0</option>
            </options>
        </field>

        <many-to-many field="articles" target-entity="Basango\Aggregator\Domain\Model\Entity\Article">
            <join-table name="bookmark_article">
                <join-columns>
                    <join-column name="bookmark_id" referenced-column-name="id" on-delete="CASCADE" />
                </join-columns>
               <inverse-join-columns>
                   <join-column name="article_id" referenced-column-name="id" on-delete="CASCADE" />
               </inverse-join-columns>
            </join-table>
        </many-to-many>

        <field name="createdAt" type="datetime_immutable"/>
        <field name="updatedAt" type="datetime_immutable" nullable="true"/>
    </entity>
</doctrine-mapping>
