OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums OroPlatform Bundle-specific Migrations: do I have to create migrations manually?

This topic contains 8 replies, has 2 voices, and was last updated by  Frank 3 months ago.

  • Creator
    Topic
  • #38988

    Frank
    Participant

    Hi there,

    reading the documentation ‘How to Use Entities’:
    https://oroinc.com/b2b-ecommerce/doc/current/dev-guide/entities/using-entities

    I failed in finding some command to create a migration scheme for predefined entities automatically.

    In Symfony 4 / doctrine one can use simply ( – however, not bundle-specific):
    command (corresponding oro-command)

    1. $ ./bin/console make:entity (?)
    2. $ ./bin/console make:migration (?)
    3. $ ./bin/console doctrine:migrations:migrate (.bin/console oro:migration:load –force)

    In Oro, how I can create migration scheme automatically?

    Thanks for help
    Frank

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #38992
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    OroPlatform uses a bit different migration architecture that plain Symfony.
    1,2 commands are not available.

    To generate the code for migrations you can use bin/console oro:migration:dump [BundleName], but the command outputs the code to the screen, you should split it to files and save manually.
    It is recommended to specify [BundleName] as an argument, otherwise, it will output the migrations for all the bundles that usually not useful.

    #38995

    Frank
    Participant

    Hi Andrey,

    correct command seems to be, right?
    bin/console oro:migration:dump –bundle [BundleName]

    My Entitiy-Classes are:
    Acme\Bundle\DemoWorkflowBundle\Entity\PhoneCall.php
    Acme\Bundle\DemoWorkflowBundle\Entity\PhoneConversation.php

    My Bundle-ClassName itself is:
    Acme\Bundle\DemoWorkflowBundle\AcmeDemoworkflowBundle.php

    Trying to put some Bundle-Name into the commandline:

    or

    generates the error:

    ‘AcmeDemoworkflowBundle is not aknown bundle’

    What I am doing still wrong?

    Thanks
    Frank

    #39005
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Square brackets were for a placeholder. Correct syntax is:

    #39006

    Frank
    Participant

    I’ve got it!

    works fine for me.

    Thank you/regards
    Frank

    #39007

    Frank
    Participant

    works too!

    Thank you.
    Frank

    #39612

    Frank
    Participant

    Hi there,

    I have to revoke my statement!

    $ bin/console oro:migration:dump –bundle=AcmeWorkflowBundle

    Generates installer-code with existing database tables only.
    It is NOT USEFUL, if one have entity-php-classes created and looks for automatic migration-code-generation!!!

    oro:migration:dump works only after bin/console doctrine:schema:update has been executed:
    https://oroinc.com/b2b-ecommerce/doc/current/dev-guide/extend-and-customize/installer-generate

    So, finally it seems, you have to generate migrations-code manually, what is not very comfortable, really!!

    Frank

    #39618
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    1) Do a database backup
    2) Run doctrine:schema:update
    3) Run oro:migration:dump
    4) Restore from a database backup
    As a result, you have auto-generated migrations for all the entity changes.

    #39712

    Frank
    Participant

    Hi Andrey,

    hm. Suggested workaround a ‘little bit’ cumbersome, as mentioned above. However it works.

    Would be very comfortable to implement into oro platform something like (available in Symfony 4):
    $ ./bin/console make:migration

    Thanks a lot.

    Kind regrads
    Frank

    (Topic closed finally)

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

You must be logged in to reply to this topic.

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

Yes No