I am working on the Doctrine ORM (2.4.8, I know, it's old I cannot do anything about it right now) part of the code (Symfony 3 again, I'm aware it's old). I need many-to-many relation here because multiple Countries might be listed in multiple LineItems. The primary key of the Country table is iso3 and I would not like to modify it.
Here is the field that should contain the countries:
class LineItem
{
...
/**
* @ORM\ManyToMany(targetEntity="CampaignBundle\...\Country", inversedBy="iso3")
* @ORM\JoinTable(
* name="lineitem_country_filter",
* joinColumns={
* @ORM\JoinColumn(name="country_id", referencedColumnName="iso3")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="lineitem_id", referencedColumnName="id")
* }
* )
*/
private $countryFilter;
...}
Here is a part of the Country class:
class Country
{...
/**
* @ORM\Column(name="iso3", type="string", length=10, unique=true)
* @ORM\Id()
* @ORM\ManyToMany(targetEntity="LineItem", mappedBy="countryFilter")
* @ORM\OneToMany(targetEntity="Region", mappedBy="country")
* @ORM\GeneratedValue(strategy="NONE")
*/
private $iso3;
...}
When I try to run symfony console d:m:diff I get this issue:
In SchemaTool.php line 648:
Column name 'iso3' referenced for relation from CampaignBundle\...\LineItem towards CampaignBundle\...\Country does not exist.
I have no idea how to solve it. Just for a small clarification, I'm a junior dev in a small company ;)