ssossossosso

Forums

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

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 3 years, 9 months ago.

  • Creator
    Topic
  • #62061

    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
  • #62062

    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.

    #62063

    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

    #62064

    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.

    #62065

    leahaense
    Participant

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

    #62067

    leahaense
    Participant

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

    #62068

    Vova Soroka
    Participant

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

    #62069

    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

    #62070

    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)

You must be logged in to reply to this topic.

ssossossosso