OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums OroCRM OroCRM – How do I? Questions Proper way to update oro_entity_config_xxx after removing a field

This topic contains 11 replies, has 6 voices, and was last updated by  Martin 1 year, 2 months ago.

  • Creator
    Topic
  • #28103
    Hiro
    Hiro
    Participant

    When I remove a field from Entity Class and apply the change to the database I do the followings:

    When I do that the field data is left in the tables “oro_entity_config_xxx” (e.g. oro_entity_config_field) and I manually have to delete the records as being troubled with the foreign keys.

    I know “php app/console oro:entity-config:xxx” commands take care when I add a new field and they do not when I delete a field.

    What is the proper way to update those tables after deleting a field?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Author
    Replies
  • #28104
    Dima Soroka
    Dima Soroka
    Keymaster

    Unfortunately this functionality is not supported yet and we are going to complete it soon. The workaround as for now is to do cleanup manually with migration scripts or regenerate the schema if you are not in production yet.

    #28105
    Hiro
    Hiro
    Participant

    Thank you for the reply.

    The problem when I tried with regenerating the schema was that the old migration scripts include some updates for Entity Config data.

    Those are not taken care by the command “php app/console oro:entity-config:xxx”.

    When I deleted all the records from Entity Config related tables and executed the commands, I could not have replicated the latest table structure (e.g. The one related to Attachment feature etc).

    I had to make OroCRM think the newest migration has not been applied for the bundle by updating the migration history table and temporally changed the code in the latest migration script to update the schema to make “php app/console oro:entity-config:xxx” work.

    So currently I plan to create the migration script if I have to remove a field from Entity as I assume that would take less time.

    #28106

    Ximousse
    Participant

    Hi,

    I’ve been facing the same problem, any news about “php app/console oro:entity-config:xxx” being functional ?

    #28107
    Dima Soroka
    Dima Soroka
    Keymaster

    We scheduled field removal support for December so far.

    #28108

    tomicevmail
    Participant

    Hi,
    is this still in progress or we have the command available?
    (for removing old fields from ‘oro_entity_config_field’ table)

    #28109

    Martin
    Participant

    Is this now implemented? We also have an old broken many-to-many custom field in the database, which causes trouble with schema updates. As for now, it doesn’t look like we could fix this.

    Kind Regards
    Martin

    #28110
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Hi Martin,

    We had to change our priorities so this was not done, and we are unlikely to implement it within this year.

    So this should be done manually at the customization side.

    #28112

    Martin
    Participant

    Hi Andrey,

    thank you for your quick replyI I’ve found some information on this topic here https://oroinc.com/orocrm/forums/topic/problem-with-field-in-schema-update which states to do this by custom migration like this https://gist.github.com/mccar/e45210d9e786e51f447db8f0d433bbca .

    Is this still the way to go and could you maybe point me in the direction on how to do this with many-to-many relation items?

    Kind regards

    #28113
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    You need to:
    1) cleanup entity field config
    2) cleanup entity config for each of many-to-many entities
    3) drop column of default value of many-to-many relation
    4) drop many-to-many table.

    #28114
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator
    #28115

    Martin
    Participant

    Yup, that worked!

    Kudos Andrey!

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

You must be logged in to reply to this topic.

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

Yes No