I'm using FOSMessage in my project (https://github.com/FriendsOfSymfony/FOSMessage) and I would like to override the table names of the entities.
For example in FOSMessage (\FOS\Message\Driver\Doctrine\ORM\Entity\Conversation) I have :
/**
* @ORM\Table(name="fos_message_conversations")
* @ORM\Entity
*/
class Conversation extends BaseConversation
...
// properties
...
And in my custom entity, I do :
/**
* @ORM\Table(name="user__message__fos_message_conversations")
* @ORM\Entity
*/
class Conversation extends \FOS\Message\Driver\Doctrine\ORM\Entity\Conversation
{
}
It works but only for "none-relation" properties. There is properties with "One-To-Many" relationships and there are ignored. When I update my database, I only have text properties and id. I don't have "messages" relation for example.
How can I do ? I only want to change table name.
oneToMany
needs association mapping on many
side, therefore you would need also custom Message
entity with mapping manyToOne
pointing your custom Conversation
.
That's because in fact in RMDBS, the foreign key is in many
side table, which in this case is message
table. There's a column conversation_id
in message and not vice versa.