From d8bf6a195fa5ca66bf4aa6d40c01e77d64c3b495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 27 Nov 2023 20:30:25 +0100 Subject: [PATCH] add creation and update information on events and participation --- src/Bundle/ChillEventBundle/Entity/Event.php | 9 ++- .../ChillEventBundle/Entity/Participation.php | 9 ++- .../migrations/Version20231127134244.php | 59 +++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillEventBundle/migrations/Version20231127134244.php diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index b5d013588..6d286f2c4 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -11,6 +11,10 @@ declare(strict_types=1); namespace Chill\EventBundle\Entity; +use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; +use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; +use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; +use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; @@ -30,8 +34,11 @@ use Doctrine\ORM\Mapping as ORM; * * @ORM\HasLifecycleCallbacks */ -class Event implements HasCenterInterface, HasScopeInterface +class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInterface, TrackUpdateInterface { + use TrackCreationTrait; + use TrackUpdateTrait; + /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center") */ diff --git a/src/Bundle/ChillEventBundle/Entity/Participation.php b/src/Bundle/ChillEventBundle/Entity/Participation.php index 464feaf30..1f7040c05 100644 --- a/src/Bundle/ChillEventBundle/Entity/Participation.php +++ b/src/Bundle/ChillEventBundle/Entity/Participation.php @@ -11,6 +11,10 @@ declare(strict_types=1); namespace Chill\EventBundle\Entity; +use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; +use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; +use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; +use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; @@ -30,8 +34,11 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * * @ORM\HasLifecycleCallbacks */ -class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface +class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface, TrackUpdateInterface, TrackCreationInterface { + use TrackCreationTrait; + use TrackUpdateTrait; + /** * @ORM\ManyToOne( * targetEntity="Chill\EventBundle\Entity\Event", diff --git a/src/Bundle/ChillEventBundle/migrations/Version20231127134244.php b/src/Bundle/ChillEventBundle/migrations/Version20231127134244.php new file mode 100644 index 000000000..8a5fa592a --- /dev/null +++ b/src/Bundle/ChillEventBundle/migrations/Version20231127134244.php @@ -0,0 +1,59 @@ +addSql('ALTER TABLE chill_event_event ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_event ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_event ADD createdBy_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_event ADD updatedBy_id INT DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_event_event.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_event_event.updatedAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC83174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC865FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_FA320FC83174800F ON chill_event_event (createdBy_id)'); + $this->addSql('CREATE INDEX IDX_FA320FC865FF1AEC ON chill_event_event (updatedBy_id)'); + $this->addSql('ALTER TABLE chill_event_participation ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_participation ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_participation ADD createdBy_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_event_participation ADD updatedBy_id INT DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_event_participation.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_event_participation.updatedAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE chill_event_participation ADD CONSTRAINT FK_4E7768AC3174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_participation ADD CONSTRAINT FK_4E7768AC65FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_4E7768AC3174800F ON chill_event_participation (createdBy_id)'); + $this->addSql('CREATE INDEX IDX_4E7768AC65FF1AEC ON chill_event_participation (updatedBy_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_event_event DROP createdAt'); + $this->addSql('ALTER TABLE chill_event_event DROP updatedAt'); + $this->addSql('ALTER TABLE chill_event_event DROP createdBy_id'); + $this->addSql('ALTER TABLE chill_event_event DROP updatedBy_id'); + $this->addSql('ALTER TABLE chill_event_participation DROP createdAt'); + $this->addSql('ALTER TABLE chill_event_participation DROP updatedAt'); + $this->addSql('ALTER TABLE chill_event_participation DROP createdBy_id'); + $this->addSql('ALTER TABLE chill_event_participation DROP updatedBy_id'); + } +}