diff --git a/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php b/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php index a8d4e274b..4cfbda0f6 100644 --- a/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php +++ b/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php @@ -58,11 +58,11 @@ class ExportGeneration implements TrackCreationInterface /** * The related saved export. * - * Note that, in some case, the options of this ExportGenration are not equals to the options of the saved export. + * Note that, in some case, the options of this ExportGeneration are not equals to the options of the saved export. * This happens when the options of the saved export are updated. */ #[ORM\ManyToOne(targetEntity: SavedExport::class)] - #[ORM\JoinColumn(nullable: true)] + #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?SavedExport $savedExport = null, ) { $this->id = Uuid::uuid4(); diff --git a/src/Bundle/ChillMainBundle/migrations/Version20250617141354.php b/src/Bundle/ChillMainBundle/migrations/Version20250617141354.php new file mode 100644 index 000000000..241b0a12f --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20250617141354.php @@ -0,0 +1,36 @@ +addSql(<<<'SQL' + ALTER TABLE chill_main_export_generation DROP CONSTRAINT FK_E644B77DA61D6F69 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_main_export_generation ADD CONSTRAINT FK_E644B77DA61D6F69 FOREIGN KEY (savedExport_id) REFERENCES chill_main_saved_export (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql(<<<'SQL' + ALTER TABLE chill_main_export_generation DROP CONSTRAINT fk_e644b77da61d6f69 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_main_export_generation ADD CONSTRAINT fk_e644b77da61d6f69 FOREIGN KEY (savedexport_id) REFERENCES chill_main_saved_export (id) NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + } +}