diff --git a/migrations/Version20240926085224.php b/migrations/Version20240926085224.php new file mode 100644 index 0000000..b05ce37 --- /dev/null +++ b/migrations/Version20240926085224.php @@ -0,0 +1,35 @@ +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)'); + } +} diff --git a/src/Entity/RemoteCalendarRule.php b/src/Entity/RemoteCalendarRule.php index 6b5a05f..419fa56 100644 --- a/src/Entity/RemoteCalendarRule.php +++ b/src/Entity/RemoteCalendarRule.php @@ -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)]