Answer the question
In order to leave comments, you need to log in
How to make 2 foreign keys for the same table in Doctrine?
Good afternoon I’ll say right away that I’m not
sure that I formed the title correctly, but I’ll try to reveal the problem here
Given:
Symfony + fosUser + doctrine + the rest is not important here
A site like a bug tracker with tickets
Tickets have such a table
id
title
text
author_id
target_user_id
That is, author_id - the one who created
the target_user_id - who is entrusted with the task
author_id - foreign key with the user table by id field - everything is clear
Then the question
is target_user_id - also foreign key with the user table by id
After accepting the changes - in the user table, the doctrine itself made the roles field of the text type, and in principle everything broke
neither the login of users works, nor any other action where the user table is at least somehow affected
. I understand that the reason is precisely in the second f.key - and the question is not so much about the code, but about the architecture and sql
1) I understand that there are two f.keys which are by and large the same in the table, they just differ in the name of the field - is it possible (most likely not) and how to do it right?
2) If more fields are added to the table that are somehow related to the user table, but with different users (for example: Author / validator / performer / tester) - what to do in such a situation?
Answer the question
In order to leave comments, you need to log in
1) It is possible to map 1...N properties of an entity onto the same entity in the above way. And that's okay.
2)
After accepting the changes - in the user table, the doctrine itself made the roles field of the text type
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question