OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Create a custom entity

This topic contains 8 replies, has 2 voices, and was last updated by  leahaense 9 years, 10 months ago.

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

  • Creator
    Topic
  • #35677

    leahaense
    Participant

    I’d like to add a custom entity with a new table in the database. I created the entity and then tried to run app/console doctrine:schema:update –dump-sql, but I got an exception:

    [Doctrine\DBAL\Schema\SchemaException]
    The table with name ‘oro_crm.oro_access_group’ already exists.

    How can I update my schema? I saw that there’s a MigrationBundle but I didn’t really understand if I can use that somehow and if yes, how. Thanks for the help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #35678

    Vova Soroka
    Participant

    It seems your entity has @ORM\Table(name=”oro_access_group”) annotation which is already used by Oro\Bundle\UserBundle\Entity\Group.

    The doctrine:schema:update works fine during development process, but to apply database changes on production you should create a migration. The easiest way to get the migration code is to run oro:migration:dump command and then find changes related to your entities in the output of this command and copy them in the migration.

    #35679

    leahaense
    Participant

    It does not. But when I search for ‘oro_access_group’ in all Oro classes I find two classes having that in the @Table annotation:

    – Oro\Bundle\DistributionBundle\Entity\Security\Group
    – Oro\Bundle\UserBundle\Entity\Group

    #35680

    Vova Soroka
    Participant

    It is ok. The Group entity from the DistributionBundle is located in Security sub directory and Doctrine should not see it as an entity, so these two classes do not conflict each other.

    #35681

    leahaense
    Participant

    Well, it does not seem like it’s ignored. But I’ll investigate a bit further.

    #35682

    leahaense
    Participant

    I get the same error on a fresh install without any additional custom entities…

    #35683

    Vova Soroka
    Participant

    It seems very strange. Please let us know if you will find the reason of this error.

    #35684

    leahaense
    Participant

    Entities in subfolders are not ignored, but I found the following in the config.yml under doctrine.orm


    mappings:
    OroDistributionBundle:
    mapping: false
    is_bundle: true

    But since auto_mapping is set to true I believe that these settings are completely ignored

    #35685

    leahaense
    Participant

    Ok, forget about it. I just remembered that I patched the doctrine bundle earlier because of some trouble when using multiple entity managers. apparently that broke this setting with excluding a bundle from the mapping. sorry :)

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

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top