From 1d21499eab651edd33e2566c9724444f5059cf6c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 29 Nov 2023 14:04:19 +0100 Subject: [PATCH] add version property to accompanyingperiodwork for optimistic locking --- .../AccompanyingPeriodWork.php | 19 ++++++++++++++ .../migrations/Version20231129113816.php | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20231129113816.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 77906b1ba..8531d7157 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -244,6 +244,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues */ private ?User $updatedBy = null; + /** + * @ORM\Column(type="integer", nullable=false, options={"default": 1}) + * + * @Serializer\Groups({"read", "read:accompanyingPeriodWork:light", "read:evaluation:include-work"}) + */ + private int $version = 1; + public function __construct() { $this->goals = new ArrayCollection(); @@ -452,6 +459,18 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->updatedBy; } + public function getVersion(): int + { + return $this->version; + } + + public function setVersion(int $version): self + { + $this->version = $version; + + return $this; + } + public function removeAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self { $this->accompanyingPeriodWorkEvaluations diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20231129113816.php b/src/Bundle/ChillPersonBundle/migrations/Version20231129113816.php new file mode 100644 index 000000000..51731db8a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20231129113816.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE chill_person_accompanying_period_work ADD version INT DEFAULT 1 NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP version'); + } +}