From 3611dfce5734cee3b1ed69d60c10da7b0f197ada Mon Sep 17 00:00:00 2001 From: mmarchois Date: Tue, 21 Jan 2025 15:26:53 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20mod=C3=A8le=20de=20donn=C3=A9e=20T?= =?UTF-8?q?oken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Domain/User/Token.php | 42 +++++++++++++++++++ .../Doctrine/Mapping/User.Token.orm.xml | 15 +++++++ .../Migrations/Version20250121142614.php | 35 ++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 src/Domain/User/Token.php create mode 100644 src/Infrastructure/Persistence/Doctrine/Mapping/User.Token.orm.xml create mode 100644 src/Infrastructure/Persistence/Doctrine/Migrations/Version20250121142614.php diff --git a/src/Domain/User/Token.php b/src/Domain/User/Token.php new file mode 100644 index 000000000..777ba1a20 --- /dev/null +++ b/src/Domain/User/Token.php @@ -0,0 +1,42 @@ +uuid; + } + + public function getToken(): string + { + return $this->token; + } + + public function getType(): string + { + return $this->type; + } + + public function getUser(): User + { + return $this->user; + } + + public function getExpirationDate(): \DateTimeInterface + { + return $this->expirationDate; + } +} diff --git a/src/Infrastructure/Persistence/Doctrine/Mapping/User.Token.orm.xml b/src/Infrastructure/Persistence/Doctrine/Mapping/User.Token.orm.xml new file mode 100644 index 000000000..c045f2fd2 --- /dev/null +++ b/src/Infrastructure/Persistence/Doctrine/Mapping/User.Token.orm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/Infrastructure/Persistence/Doctrine/Migrations/Version20250121142614.php b/src/Infrastructure/Persistence/Doctrine/Migrations/Version20250121142614.php new file mode 100644 index 000000000..422e71fc3 --- /dev/null +++ b/src/Infrastructure/Persistence/Doctrine/Migrations/Version20250121142614.php @@ -0,0 +1,35 @@ +addSql('CREATE TABLE token (uuid UUID NOT NULL, user_uuid UUID NOT NULL, token VARCHAR(100) NOT NULL, type VARCHAR(20) NOT NULL, expiration_date TIMESTAMP(0) WITH TIME ZONE NOT NULL, PRIMARY KEY(uuid))'); + $this->addSql('CREATE INDEX IDX_5F37A13BABFE1C6F ON token (user_uuid)'); + $this->addSql('CREATE INDEX IDX_5F37A13B5F37A13B ON token (token)'); + $this->addSql('ALTER TABLE token ADD CONSTRAINT FK_5F37A13BABFE1C6F FOREIGN KEY (user_uuid) REFERENCES "user" (uuid) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE token DROP CONSTRAINT FK_5F37A13BABFE1C6F'); + $this->addSql('DROP TABLE token'); + } +}