Hi guys,

Just thought this might spare someone some headaches. I was trying to 
reverse engineer a MySQL DB, but constantly got:

[Doctrine\ORM\Mapping\MappingException]                                     
 
  Property "idSalesorder" in "Orderline" was already declared, but it must 
be  
   declared only once

Most answers pointed to Doctrine not supporting a foreign key as a primary 
key, which was not my case (and is no longer an issue AFAIK). Looking at my 
table structure in PHPMyAdmin revealed nothing strange, but doing a:

show create table orderline;

Revealed these weird foreign key definitions:

  CONSTRAINT `orderline_ibfk_1` FOREIGN KEY (`id_salesorder`) REFERENCES 
`salesorder` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ... (more FK definitions) ...
  CONSTRAINT `orderline_ibfk_4` FOREIGN KEY (`id_salesorder`) REFERENCES 
`salesorder` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,

For some strange reason I cannot grasp, since I did not create my tables 
manually, the exact same FK was set up twice with two different constraint 
names!

The solution was simple, i just did a "ALTER TABLE salesorder DROP FOREIGN 
KEY orderline_ibfk_4" and voilĂ !

Please be aware that PHPMyAdmin does not show the duplicate FK's neither in 
the relation view or the indexes. "show create table" was the only way I 
could catch this.

Cheers!
Hlodowig

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to