-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Domain\User; | ||
|
||
class Token | ||
{ | ||
public function __construct( | ||
private string $uuid, | ||
private string $token, | ||
private string $type, | ||
private User $user, | ||
private \DateTimeInterface $expirationDate, | ||
) { | ||
} | ||
|
||
public function getUuid(): string | ||
{ | ||
return $this->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; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Infrastructure/Persistence/Doctrine/Mapping/User.Token.orm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> | ||
<entity name="App\Domain\User\Token" table="token"> | ||
<indexes> | ||
<index columns="token"/> | ||
</indexes> | ||
<id name="uuid" type="guid" column="uuid"/> | ||
<field name="token" type="string" length="100" nullable="false"/> | ||
<field name="type" type="string" length="20" nullable="false"/> | ||
<field name="expirationDate" type="datetimetz" nullable="false"/> | ||
<many-to-one field="user" target-entity="App\Domain\User\User"> | ||
<join-column name="user_uuid" nullable="false" referenced-column-name="uuid" on-delete="CASCADE"/> | ||
</many-to-one> | ||
</entity> | ||
</doctrine-mapping> |
35 changes: 35 additions & 0 deletions
35
src/Infrastructure/Persistence/Doctrine/Migrations/Version20250121142614.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Infrastructure\Persistence\Doctrine\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20250121142614 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->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'); | ||
} | ||
} |