php - Doctrine2 Duplicate key name error -


i'm trying use doctrine2 migration , schema update symfony2's console. entities being generated no problems via:

php app/console doctrine:generate:entities myproject 

also, able create database , build schema scratch no problems given following commands:

php app/console doctrine:database:create php app/console doctrine:schema:create 

whenever modify, remove, or add in entity, regenerate entities with:

php app/console doctrine:generate:entities myproject 

the problem however, whenever want update schema following error:

  [doctrine\dbal\dbalexception]                                                   exception occurred while executing 'create index idx_f7129a80a76ed395 on      user_user (user_id)':                                                           sqlstate[42000]: syntax error or access violation: 1061 duplicate key name      'idx_f7129a80a76ed395'                                                                [pdoexception]                                                                  sqlstate[42000]: syntax error or access violation: 1061 duplicate key name      'idx_f7129a80a76ed395'  

i have tried doing:

php app/console doctrine:schema:update --force 

or

php app/console doctrine:migrations:diff php app/console doctrine:migrations:migrate 

but same error. doing wrong? there way me update database without having destroy , build whole new 1 every time? have on 25 entities consist of large files many associative mappings (onetoone, onetomany, manytomany,.. etc) seems causing problems. great! thanks!

on side note have feeling piece of code might causing problem:

/**  * @orm\ manytomany(targetentity="user", inversedby="myfriends")  */ protected $friendswithme;  /**  * @orm\ manytomany(targetentity="user", inversedby="friendswithme")  * @orm\ jointable(name="friends",  *      joincolumns={@orm\ joincolumn(name="user_id", referencedcolumnname="id")},  *      inversejoincolumns={@orm\ joincolumn(name="friend_user_id", referencedcolumnname="id")}  *      )  **/ protected $myfriends; 

in user entity, wanted build self-referencing many many relationship. how i'm building out friends list. maybe there wrong logic, took directly off doctrine2 documentation on associative mapping.

not sure cause of exception, there error in orm mapping. $myfriends owning side, $friendswithme inverse side, inversedby attribute should present on $friendswithme.

try rewrite $myfriendswith mappedby attribute :

/**  * @orm\ manytomany(targetentity="user", mappedby="friendswithme")  * @orm\ jointable(name="friends",  *      joincolumns={@orm\ joincolumn(name="user_id", referencedcolumnname="id")},  *      inversejoincolumns={@orm\ joincolumn(name="friend_user_id", referencedcolumnname="id")}  *      )  **/ protected $myfriends; 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -