diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index 73e98c0dd..649de0422 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -10,6 +10,7 @@ use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\HasCenterInterface; use Symfony\Component\Validator\Constraints as Assert; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; +use Chill\PersonBundle\Entity\AccompanyingPeriod; /** * AbstractTask @@ -67,9 +68,16 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface * @ORM\ManyToOne( * targetEntity="\Chill\PersonBundle\Entity\Person" * ) - * @Assert\NotNull() */ private $person; + + + /** + * @var AccompanyingPeriod + * @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod") + */ + + private $course; /** * @@ -202,6 +210,11 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface return $this->person; } + public function getCourse(): ?AccompanyingPeriod + { + return $this->course; + } + public function getCircle(): ?Scope { return $this->circle; @@ -219,6 +232,12 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface return $this; } + public function setCourse(AccompanyingPeriod $course) + { + $this->course = $course; + return $this; + } + public function setCircle(Scope $circle) { $this->circle = $circle; diff --git a/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php new file mode 100644 index 000000000..e2f59621b --- /dev/null +++ b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE chill_task.recurring_task ADD course_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B90591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_9F663B90591CC992 ON chill_task.recurring_task (course_id)'); + $this->addSql('ALTER TABLE chill_task.single_task ADD course_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D8591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_194CB3D8591CC992 ON chill_task.single_task (course_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_task.recurring_task DROP CONSTRAINT FK_9F663B90591CC992'); + $this->addSql('ALTER TABLE chill_task.recurring_task DROP course_id'); + $this->addSql('ALTER TABLE chill_task.single_task DROP CONSTRAINT FK_194CB3D8591CC992'); + $this->addSql('ALTER TABLE chill_task.single_task DROP course_id'); + } +}