From 58f1984c7770bac5d51ee7d4b17635dd5047ffc9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 15:14:13 +0100 Subject: [PATCH] Add new fields to AddressReference for update procedure --- .../Entity/AddressReference.php | 55 +++++++++++++++++++ .../migrations/Version20220325134944.php | 43 +++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20220325134944.php diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index a9d421fcb..fe132f883 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity; use Chill\MainBundle\Doctrine\Model\Point; +use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; @@ -33,6 +34,18 @@ class AddressReference */ private string $addressCanonical = ''; + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $createdAt = null; + + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $deletedAt = null; + /** * @ORM\Id * @ORM\GeneratedValue @@ -89,6 +102,22 @@ class AddressReference */ private $streetNumber; + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $updatedAt = null; + + public function getCreatedAt(): ?DateTimeImmutable + { + return $this->createdAt; + } + + public function getDeletedAt(): ?DateTimeImmutable + { + return $this->deletedAt; + } + public function getId(): ?int { return $this->id; @@ -134,6 +163,25 @@ class AddressReference return $this->streetNumber; } + public function getUpdatedAt(): ?DateTimeImmutable + { + return $this->updatedAt; + } + + public function setCreatedAt(?DateTimeImmutable $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } + + public function setDeletedAt(?DateTimeImmutable $deletedAt): self + { + $this->deletedAt = $deletedAt; + + return $this; + } + public function setMunicipalityCode(?string $municipalityCode): self { $this->municipalityCode = $municipalityCode; @@ -189,4 +237,11 @@ class AddressReference return $this; } + + public function setUpdatedAt(?DateTimeImmutable $updatedAt): self + { + $this->updatedAt = $updatedAt; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php b/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php new file mode 100644 index 000000000..bc0382482 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php @@ -0,0 +1,43 @@ +addSql('ALTER TABLE chill_main_address_reference DROP createdAt'); + $this->addSql('ALTER TABLE chill_main_address_reference DROP deletedAt'); + $this->addSql('ALTER TABLE chill_main_address_reference DROP updatedAt'); + } + + public function getDescription(): string + { + return 'Add 3 fields on AddressReference'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_address_reference ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD deletedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.deletedAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.updatedAt IS \'(DC2Type:datetime_immutable)\''); + } +}