From 84b20f8ebdc115f5fbf567b05b97db22be198368 Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Tue, 7 Oct 2025 14:01:52 +0200 Subject: [PATCH] Fix timestamp bugs for collaborations and rewards --- migrations/Version20251007115926.php | 41 +++++++++++++++++++ src/ApiResource/Project/RewardApiResource.php | 4 ++ src/Entity/Project/Collaboration.php | 8 ++-- src/Entity/Project/Reward.php | 4 ++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 migrations/Version20251007115926.php diff --git a/migrations/Version20251007115926.php b/migrations/Version20251007115926.php new file mode 100644 index 0000000..f55e41e --- /dev/null +++ b/migrations/Version20251007115926.php @@ -0,0 +1,41 @@ +addSql(<<<'SQL' + ALTER TABLE project_collaboration ADD date_created DATETIME NOT NULL, ADD date_updated DATETIME NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE project_reward ADD date_created DATETIME NOT NULL, ADD date_updated DATETIME NOT NULL + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + ALTER TABLE project_reward DROP date_created, DROP date_updated + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE project_collaboration DROP date_created, DROP date_updated + SQL); + } +} diff --git a/src/ApiResource/Project/RewardApiResource.php b/src/ApiResource/Project/RewardApiResource.php index 2383630..9b03bf0 100644 --- a/src/ApiResource/Project/RewardApiResource.php +++ b/src/ApiResource/Project/RewardApiResource.php @@ -9,6 +9,8 @@ use ApiPlatform\Doctrine\Orm\State\Options; use ApiPlatform\Metadata as API; use App\ApiResource\LocalizedApiResourceTrait; use App\ApiResource\MoneyWithConversion; +use App\ApiResource\TimestampedCreationApiResource; +use App\ApiResource\TimestampedUpdationApiResource; use App\Entity\Project\Reward; use App\State\ApiResourceStateProvider; use App\State\Project\RewardStateProcessor; @@ -29,6 +31,8 @@ use Symfony\Component\Validator\Constraints as Assert; class RewardApiResource { use LocalizedApiResourceTrait; + use TimestampedCreationApiResource; + use TimestampedUpdationApiResource; #[API\ApiProperty(identifier: true, writable: false)] public int $id; diff --git a/src/Entity/Project/Collaboration.php b/src/Entity/Project/Collaboration.php index d4a48aa..5bc075a 100644 --- a/src/Entity/Project/Collaboration.php +++ b/src/Entity/Project/Collaboration.php @@ -2,9 +2,9 @@ namespace App\Entity\Project; -use App\ApiResource\TimestampedCreationApiResource; -use App\ApiResource\TimestampedUpdationApiResource; use App\Entity\Trait\LocalizedEntityTrait; +use App\Entity\Trait\TimestampedCreationEntity; +use App\Entity\Trait\TimestampedUpdationEntity; use App\Mapping\Provider\EntityMapProvider; use App\Repository\Project\CollaborationRepository; use AutoMapper\Attribute\MapProvider; @@ -18,8 +18,8 @@ use Gedmo\Mapping\Annotation as Gedmo; class Collaboration { use LocalizedEntityTrait; - use TimestampedCreationApiResource; - use TimestampedUpdationApiResource; + use TimestampedCreationEntity; + use TimestampedUpdationEntity; #[ORM\Id] #[ORM\GeneratedValue] diff --git a/src/Entity/Project/Reward.php b/src/Entity/Project/Reward.php index 13169e1..b6da54e 100644 --- a/src/Entity/Project/Reward.php +++ b/src/Entity/Project/Reward.php @@ -6,6 +6,8 @@ use App\Entity\EmbeddableMoney as Money; use App\Entity\Interface\LocalizedEntityInterface; use App\Entity\Trait\LocalizedEntityTrait; use App\Entity\Trait\MigratedEntity; +use App\Entity\Trait\TimestampedCreationEntity; +use App\Entity\Trait\TimestampedUpdationEntity; use App\Mapping\Provider\EntityMapProvider; use App\Repository\Project\RewardRepository; use AutoMapper\Attribute\MapProvider; @@ -25,6 +27,8 @@ class Reward implements LocalizedEntityInterface { use MigratedEntity; use LocalizedEntityTrait; + use TimestampedCreationEntity; + use TimestampedUpdationEntity; #[ORM\Id] #[ORM\GeneratedValue]