'doctrine migrations with postgresql : on delete cascade not anymore in migrations
When I add a foreign key with symfony maker, then generate my migration whith php bin/console d:m:diff there is no more this instruction :
ON DELETE CASCADE
For example, I had a ManyToOne
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $userCreation;
In the past (08/04/2022), my migration was that kind :
public function up(Schema $schema): void
{
....
$this->addSql('ALTER TABLE myTable ADD CONSTRAINT FK_21DFB03EA76ED395 FOREIGN KEY (user_id) REFERENCES utilisateur (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
Now, if I do the same, I have :
public function up(Schema $schema): void
{
....
$this->addSql('ALTER TABLE myTable ADD CONSTRAINT FK_D80C797B46501A53 FOREIGN KEY (user_id) REFERENCES utilisateur (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
Now, I must add this orm description to find again the ON DELETE CASCADE instruction :
@ORM\JoinColumn(onDelete="CASCADE")
did I missed an update or something ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
