diff --git a/migrations/Version20230322154120.php b/migrations/Version20230322154120.php new file mode 100644 index 00000000000..ba400dcde74 --- /dev/null +++ b/migrations/Version20230322154120.php @@ -0,0 +1,27 @@ +addSql('ALTER TABLE geo_city DROP FOREIGN KEY FK_297C2D349D25CF90'); + $this->addSql('ALTER TABLE + geo_city + ADD + CONSTRAINT FK_297C2D349D25CF90 FOREIGN KEY (replacement_id) REFERENCES geo_city (id) ON DELETE CASCADE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE geo_city DROP FOREIGN KEY FK_297C2D349D25CF90'); + $this->addSql('ALTER TABLE + geo_city + ADD + CONSTRAINT FK_297C2D349D25CF90 FOREIGN KEY (replacement_id) REFERENCES geo_city (id) ON UPDATE NO ACTION ON DELETE NO ACTION'); + } +} diff --git a/src/Entity/Geo/City.php b/src/Entity/Geo/City.php index 4629d3fd1d7..fdc2263424b 100644 --- a/src/Entity/Geo/City.php +++ b/src/Entity/Geo/City.php @@ -65,6 +65,7 @@ class City implements ZoneableInterface * @var City|null * * @ORM\ManyToOne(targetEntity="App\Entity\Geo\City") + * @ORM\JoinColumn(onDelete="CASCADE") */ private $replacement; diff --git a/src/Normalizer/ItemNormalizerDecorator.php b/src/Normalizer/ItemNormalizerDecorator.php index d9507920edb..69d272c0ec7 100644 --- a/src/Normalizer/ItemNormalizerDecorator.php +++ b/src/Normalizer/ItemNormalizerDecorator.php @@ -264,7 +264,6 @@ public function denormalize($data, $class, $format = null, array $context = []) $context['api_denormalize'] = true; - # GOTO: if ($this->resourceClassResolver->isResourceClass($class)) { $newResourceClass = $this->resourceClassResolver->getResourceClass($objectToPopulate, $class); if (!(new \ReflectionClass($newResourceClass))->isAbstract()) {