OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Installation/Technical Issues or Problems Bug in command oro:cron:imap-sync + add migration not loaded

This topic contains 6 replies, has 4 voices, and was last updated by  adriwan_kenoby 6 years ago.

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

  • Creator
    Topic
  • #27829

    adriwan_kenoby
    Participant

    Hi Oro Team,

    During the integration process, EmailRecipient entities are created. These EmailRecipients have a name column which is a string but sometimes, there is a lot of adddresses in this field and synchronisation fail because name is a Doctrine type string and not a text (TINYTEXT).

    I have made a migration to workaround this problem. But my migration is override when i run doctrine:schema:update.

    I supposed this is due to version number of the migration…
    What is the version number i have to set to keep my database structure ?

    Kind regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #27830

    mlukaszewicz
    Participant

    Hello adriwan_kenoby,

    this is happening because your mapping in entity is not changed. Please add Listener to change this field metadata.
    Here you have an example how to do this:
    http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#load-classmetadata-event

    Best,
    Martin

    #27831

    adriwan_kenoby
    Participant

    Ok, thanks for your reply but i don’t understand well.

    Why I have to deal with doctrine Events ?

    Where I have to put this code ? It seems strange if i have to wrote code for event + event listener, moreover, what if i never dispatch this event…

    Their is nothing to this point in the oro doc !..

    #27832

    msulima
    Moderator

    Hello.

    To change schema please use number of migration in bundle that next from already installed in your system.

    So, for example in your bundle you already have some migrations in namespace ‘Sinabs\Bundle\ExtendEmailBundle\Migrations\Schema\v1_0’ and they already applied.

    Create new migration in namespace ‘Sinabs\Bundle\ExtendEmailBundle\Migrations\Schema\v1_1’.

    Then just run


    #27833

    adriwan_kenoby
    Participant

    I have already change the schema but I don’t understand why I have to replay my migration.

    Moreover I don’t want to create a new migration each time I run the doctrine:schema:update command.

    Can you explain me how to make migrations persistent even if I want to update the database after the migration.

    I think its a bug, but maybe i am wrong.

    #27834

    Alexander
    Moderator

    Hi @adriwan_kenoby,

    Let’s get back to the very beginning. So, you have added an a Migration in your own Bundle that makes changes in the core entity ‘EmailRecipients’ and after that you execute the ‘doctrine:schema:update’ command.
    But the entity metadata has not changed (only schema has changed), so the execution of the ‘doctrine:schema:update’ command leads to the result when your changes are reverted.
    Please take a look into Doctrine doc – https://symfony.com/doc/2.8/doctrine.html#creating-the-database-tables-schema

    So, to make your changes persistent you will need to override core entity and change annotations OR add Listener to change this field metadata (as Martin mentioned above)
    And there are some listeners in the code – you can quickly find them by tag ‘name: doctrine.event_listener, event: loadClassMetadata’ in ‘service.yml’ files and take any as an example to write your own.

    #27835

    adriwan_kenoby
    Participant

    Thank you Alexander for this explanation.

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

The forum ‘OroCRM – Installation/Technical Issues or Problems’ is closed to new topics and replies.

Back to top