add version property to accompanyingperiodwork for optimistic locking

This commit is contained in:
Julie Lenaerts 2023-11-29 14:04:19 +01:00 committed by Julien Fastré
parent 8ef001e67e
commit 1d21499eab
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 45 additions and 0 deletions

View File

@ -244,6 +244,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
*/ */
private ?User $updatedBy = null; 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() public function __construct()
{ {
$this->goals = new ArrayCollection(); $this->goals = new ArrayCollection();
@ -452,6 +459,18 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->updatedBy; 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 public function removeAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
{ {
$this->accompanyingPeriodWorkEvaluations $this->accompanyingPeriodWorkEvaluations

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20231129113816 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add versioning to accompanying period work';
}
public function up(Schema $schema): void
{
$this->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');
}
}