From af2eca0d03d534e7e0c9e825c90eb83a162191f4 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 4 Jan 2022 14:37:16 +0100 Subject: [PATCH] Change accompanyingCourse Resources comment by a string --- .../Entity/AccompanyingPeriod/Resource.php | 11 +++--- .../migrations/Version20220104133334.php | 35 +++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220104133334.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php index a11dc9b3d..c7285a7b0 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php @@ -44,9 +44,10 @@ class Resource private ?AccompanyingPeriod $accompanyingPeriod = null; /** - * @ORM\ManyToOne(targetEntity=Comment::class) + * @ORM\Column(type="text", nullable=true) + * @Groups({"read", "write"}) */ - private $comment; + private string $comment = ''; /** * @ORM\Id @@ -75,7 +76,7 @@ class Resource return $this->accompanyingPeriod; } - public function getComment(): ?Comment + public function getComment(): ?string { return $this->comment; } @@ -111,9 +112,9 @@ class Resource return $this; } - public function setComment(?Comment $comment): self + public function setComment(?string $comment = null): self { - $this->comment = $comment; + $this->comment = (string) $comment; return $this; } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220104133334.php b/src/Bundle/ChillPersonBundle/migrations/Version20220104133334.php new file mode 100644 index 000000000..23c2808c0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220104133334.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE chill_person_accompanying_period_resource DROP CONSTRAINT fk_dc78989ff8697d13'); + $this->addSql('DROP INDEX idx_dc78989ff8697d13'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD comment TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_resource DROP comment_id'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD comment_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_resource DROP comment'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT fk_dc78989ff8697d13 FOREIGN KEY (comment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX idx_dc78989ff8697d13 ON chill_person_accompanying_period_resource (comment_id)'); + } +}