refs #724. Updated onDelete logic

feature/calendars
Manuel Aranda Rosales 2024-09-26 10:54:31 +02:00
parent f928a1db11
commit fc5fd7421b
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240926085224 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE');
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE remote_calendar_id remote_calendar_id INT NOT NULL');
$this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE');
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE remote_calendar_id remote_calendar_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
}
}

View File

@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
class RemoteCalendarRule extends AbstractEntity
{
#[ORM\ManyToOne(inversedBy: 'rules')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?RemoteCalendar $remoteCalendar = null;
#[ORM\Column(type: Types::JSON, nullable: true)]