Doctrine 2 - Disallow null value on foreign keys of ManyToOne relationships
https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/annotations-reference.html#annref_joincolumn
Add nullable = false
to the JoinColumn
annotation:
@ORM\JoinColumn(..., nullable=false)
Just posting because @zim32 didn't tell where we should put the statement, so i had to make a trial and error.
Yaml:
manyToOne:
{field}:
targetEntity: {Entity}
joinColumn:
name: {field}
nullable: false
referencedColumnName: {id}
cascade: ['persist']