diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 9104f6131..760b36efb 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -169,6 +169,12 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface */ private ?User $mainUser = null; + /** + * @ORM\ManyToOne(targetEntity=Person::class) + * @ORM\JoinColumn(nullable=true) + */ + private ?Person $person; + /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars") * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") @@ -379,6 +385,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this->mainUser; } + public function getPerson(): ?Person + { + return $this->person; + } + /** * @return Collection|Person[] */ @@ -639,6 +650,13 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this; } + public function setPerson(?Person $person): Calendar + { + $this->person = $person; + + return $this; + } + public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self { $this->privateComment = $privateComment; diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php b/src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php new file mode 100644 index 000000000..732b975e3 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE chill_calendar.calendar DROP person_id'); + } + + public function getDescription(): string + { + return 'Associate a calendar with a person'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_calendar.calendar ADD person_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315AC217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_712315AC217BBB47 ON chill_calendar.calendar (person_id)'); + } +}