From b490f4a82c83f7b063775bc389eeab2fe0098c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Apr 2021 12:58:47 +0200 Subject: [PATCH 1/6] fix migration for parcours - rename sequence for closing motive --- .../migrations/Version20210419105054.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210419105054.php diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210419105054.php b/src/Bundle/ChillPersonBundle/migrations/Version20210419105054.php new file mode 100644 index 000000000..c2b752822 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210419105054.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE chill_person_closingmotive_id_seq RENAME TO ' + . 'chill_person_accompanying_period_closingmotive_id_seq'); + + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive_id_seq ' + . 'RENAME TO chill_person_closingmotive_id_seq'); + } +} From 51e9b1fcf20474923a8bf0ec1ffd451f499121e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Apr 2021 13:24:15 +0200 Subject: [PATCH 2/6] AccompanyingPeriod/Origin: set label as json --- .../Entity/AccompanyingPeriod/Origin.php | 2 +- .../migrations/Version20210419105940.php | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php index 4016cd833..42c75efca 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php @@ -39,7 +39,7 @@ class Origin private $id; /** - * @ORM\Column(type="string", length=255) + * @ORM\Column(type="json") */ private $label; diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php b/src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php new file mode 100644 index 000000000..4214c7069 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label TYPE JSON USING json_build_object(\'fr\', label)::jsonb'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label DROP DEFAULT'); + } + + public function down(Schema $schema) : void + { + // this will keep the '"' at first and last character, but is acceptable + $this->addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label TYPE VARCHAR(255) USING label->\'fr\'::text'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label DROP DEFAULT'); + } +} From b7d6d29fac8c505a8a25aeb3f23f37b3e3bcfbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Apr 2021 13:29:17 +0200 Subject: [PATCH 3/6] AccompanyingPeriod/ClosingMotive: fix json_array deprecated --- .../AccompanyingPeriod/ClosingMotive.php | 2 +- .../migrations/Version20210419112619.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210419112619.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php index 1bb48da00..4e334b2aa 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php @@ -47,7 +47,7 @@ class ClosingMotive /** * @var array * - * @ORM\Column(type="json_array") + * @ORM\Column(type="json") */ private $name; diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210419112619.php b/src/Bundle/ChillPersonBundle/migrations/Version20210419112619.php new file mode 100644 index 000000000..919fe4cff --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210419112619.php @@ -0,0 +1,29 @@ +addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS NULL'); + } + + public function down(Schema $schema) : void + { + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\''); + } +} From c5b4a44ff3305988e530d34fc752ff51ecc1f232 Mon Sep 17 00:00:00 2001 From: Christophe Siraut Date: Fri, 16 Apr 2021 11:14:45 +0200 Subject: [PATCH 4/6] AccompanyingPeriodParticipation: set cascade=persist for accompanyingPeriod fixes : A new entity was found through the relationship 'Chill\PersonBundle\Entity\AccompanyingPeriodParticipation#accompanyingPeriod' that was not configured t o cascade persist operations for entity: Chill\PersonBundle\Entity\AccompanyingPeriod@0000000002b1d44a000000002510e4e2. To solve this issue: Either explici tly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'Chill\PersonBundle\Entity\AccompanyingPeriod#__toString()' to get a clue. --- .../Entity/AccompanyingPeriodParticipation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php index 9a807b179..c22e84e42 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php @@ -50,7 +50,7 @@ class AccompanyingPeriodParticipation private $person; /** - * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations") + * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"}) * @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false) */ private $accompanyingPeriod; From 9539214d24e36edd0b82c16281ddda2e2e5f6533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Apr 2021 13:34:03 +0200 Subject: [PATCH 5/6] add some constants string to constants --- .../Entity/AccompanyingPeriod.php | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a7311f838..efb7bd8c1 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -42,7 +42,37 @@ use Chill\MainBundle\Entity\User; */ class AccompanyingPeriod { - const INTENSITY = ['occasional', 'regular']; + /** + * Mark an accompanying period as "occasional" + * + * used in INTENSITY + */ + public const INTENSITY_OCCASIONAL = 'occasional'; + + /** + * Mark an accompanying period as "regular" + * + * used in INTENSITY + */ + public const INTENSITY_REGULAR = 'regular'; + + public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR]; + + /** + * Mark an accompanying period as "draft". + * + * This means that the accompanying period is not yet + * confirmed by the creator + */ + public const STEP_DRAFT = 'DRAFT'; + + /** + * Mark an accompanying period as "confirmed". + * + * This means that the accompanying period **is** + * confirmed by the creator + */ + public const STEP_CONFIRMED = 'CONFIRMED'; /** * @var integer @@ -117,7 +147,7 @@ class AccompanyingPeriod * @var string * @ORM\Column(type="string", length=32, nullable=true) */ - private $step = 'DRAFT'; + private $step = self::STEP_DRAFT; /** * @ORM\ManyToOne(targetEntity=Origin::class) From e9674dd334ba250c2a88a8af55cde509ad34a881 Mon Sep 17 00:00:00 2001 From: Christophe Siraut Date: Fri, 16 Apr 2021 11:52:48 +0200 Subject: [PATCH 6/6] fixtures: really find Charline --- src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 4e9ea028e..180491c1f 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -89,7 +89,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co { $charline = $this->container->get('doctrine.orm.entity_manager') ->getRepository('ChillPersonBundle:Person') - ->findOneBy(array('lastName' => 'Charline')) + ->findOneBy(array('firstName' => 'Charline', 'lastName' => 'Depardieu')) ; $report = (new Report())