OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Create OneToOne relationship with migrations

This topic contains 5 replies, has 4 voices, and was last updated by  Geoffroy Cochard 7 years, 2 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #33703

    Pavel Levin

    I wan`t create OneToOne relationship between entities using migration, but in the ExtendExtension class i found only addOneToManyRelation, addManyToOneRelation and addManyToManyRelation methods. How i can create OneToOne relationship?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
  • #33704


    me neither! Have you found a solution for this yet?

    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)


    Pavel Levin

    Unfortunately, solutions, except the use of neToMany relationship, I have not found



    Hi! To create OneToOne relationship using migration, you can use Doctrine native methods Doctrine\DBAL\Schema\Table::addColumn() and Doctrine\DBAL\Schema\Table::addForeignKeyConstraint()



    hi @hugeval, thanks but that is not what I am looking for(probably I wasn’t clear enough in my question)
    What I am trying to do is to create a migration extension for my bundle so that other bundles can use it in their migration classes and add the association dynamically – much like you use the noteExtension.

    This means that my migration extension class (implements ExtendExtensionAwareInterface) needs to use the injected Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension class to add these relationships.

    On ExtendExtension the methods for doing this are: addOneToManyRelation, addManyToOneRelation and addManyToManyRelation, but i am missing addOneToOneRelation.

    ref.: https://github.com/orocrm/platform/tree/master/src/Oro/Bundle/EntityExtendBundle#add-relation

    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)


    Geoffroy Cochard


    As said @hugeval, to create a OneToOne relationship through migrations i’m using this to link orocrm_contact to partner_table by example.
    But when Entity\Extend is generated, methods to manage OneToMany is generated …
    My DB schema is correct (FK Ok, Relation OK)

    In database line config is generated like this :

    And Entity\Extend in cache about “partner” Relation :

Viewing 5 replies - 1 through 5 (of 5 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top