mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-22 18:24:23 +00:00
Set ON DELETE SET NULL
for savedExport
foreign key in ExportGeneration
entity and related migration
This commit is contained in:
parent
ea4cbfe3b9
commit
49607e431f
@ -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();
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20250617141354 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'When a row in chill_main_saved_export is deleted, set the references to NULL in chill_main_export_generation table';
|
||||
}
|
||||
|
||||
public function up(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) 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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user