How to change and entity type in Doctrine2 CTI Inheritance

前端 未结 4 1027
走了就别回头了
走了就别回头了 2020-12-17 18:38

How (if possible at all) do you change the entity type with Doctrine2, using it\'s Class Table Inheritance?

Let\'s say I have a Person parent class type

4条回答
  •  臣服心动
    2020-12-17 19:00

    I was looking for this behaviour yesterday also.

    In the end, after speaking with people in #doctrine on freenode, I was told that it is not possible.

    If you want to do this, then you have to go through this:

    Upgrading a User

    1. Grab the Person Entity.
    2. Update the discrimator column so that it is no longer a 'person' and change it to 'employee'
    3. Create a corresponding row inyour Employee table for this inheritance.

    Removing Inheritance

    Likewise if you want to remove inheritance, you have to..

    1. Grab the Person Entity.
    2. Update the discrimnator column so that it is no longer an 'employee' and change it to a 'person'.
    3. Delete the corresponding row in your Employee table. (Yes you have to delete it, just change the discrimator coumn is not sufficient).

    This might be 7 months late, but it is at least the correct answer for anything else looking to suport such a feature.

提交回复
热议问题