ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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 adriwan_kenoby 4 months, 2 weeks ago.

  • Creator
    Topic
  • #56733
    adriwan_kenoby
    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
  • #56736
    mlukaszewicz
    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

    #56737
    adriwan_kenoby
    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 !..

    #56739
    msulima
    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


    #65388
    adriwan_kenoby
    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.

    #65416

    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.

    #65873
    adriwan_kenoby
    adriwan_kenoby
    Participant

    Thank you Alexander for this explanation.

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

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No
ssossossosso