M
M
Maxim Morozov2021-03-11 17:02:21
Doctrine ORM
Maxim Morozov, 2021-03-11 17:02:21

How to make multiple ManyToMany relationships between two entities?

There are two entities: Event and User . An Event can have multiple attendees and multiple hosts, all of whom are users. That is, we need two fields in a table with many-to-many relationships.

If you create entities using make:entity , then there is no problem. But as soon as I try to create a migration with make:migration an error occurs

[Doctrine\DBAL\Schema\SchemaException (20)]
The table with name 'event_user' already exists.


That is, the script tries to create two service tables to link ManyToMany fields with the same name and stops with an error.

How to be in that case? Maybe you can't do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Morozov, 2021-03-11
@murzix

The question is removed. The error was in the table structure. Information about the user's role within the event should be stored separately, then there will be no problems with relationships.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question