feat: add createdAt to Connector and Watchlist

This commit is contained in:
Maël Gangloff
2024-08-03 01:40:18 +02:00
parent af6bf4eebd
commit e26360a523
7 changed files with 88 additions and 4 deletions

View File

@@ -98,7 +98,6 @@ final class Version20240726182804 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE domain DROP CONSTRAINT FK_A7A91E0B50F7084E');
$this->addSql('ALTER TABLE domain_nameservers DROP CONSTRAINT FK_B6E6B63AAF923913');
$this->addSql('ALTER TABLE domain_nameservers DROP CONSTRAINT FK_B6E6B63AA6496BFE');

View File

@@ -28,7 +28,6 @@ final class Version20240727213730 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE domain_event_id_seq CASCADE');
$this->addSql('DROP SEQUENCE entity_event_id_seq CASCADE');
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');

View File

@@ -33,7 +33,6 @@ final class Version20240729131244 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE watch_list_trigger DROP CONSTRAINT FK_CF857A4C4D085745');
$this->addSql('ALTER TABLE connector DROP CONSTRAINT FK_148C456EA76ED395');
$this->addSql('DROP TABLE connector');

View File

@@ -32,7 +32,6 @@ final class Version20240730193422 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE watch_list_trigger ADD connector_id UUID DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN watch_list_trigger.connector_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE watch_list_trigger ADD CONSTRAINT fk_cf857a4c4d085745 FOREIGN KEY (connector_id) REFERENCES connector (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240802232844 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('ALTER TABLE connector ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL');
$this->addSql('COMMENT ON COLUMN connector.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE watch_list ADD name VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE watch_list ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL');
$this->addSql('COMMENT ON COLUMN watch_list.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE connector ALTER created_at DROP DEFAULT');
$this->addSql('ALTER TABLE watch_list ALTER created_at DROP DEFAULT');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE connector DROP created_at');
$this->addSql('ALTER TABLE watch_list DROP name');
$this->addSql('ALTER TABLE watch_list DROP created_at');
}
}

View File

@@ -60,6 +60,10 @@ class Connector
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'connector')]
private Collection $watchLists;
#[Groups(['connector:list', 'watchlist:list'])]
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
public function __construct()
{
$this->id = Uuid::v4();
@@ -136,4 +140,16 @@ class Connector
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
}

View File

@@ -97,11 +97,20 @@ class WatchList
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
private ?Connector $connector = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
private ?string $name = null;
#[ORM\Column]
#[Groups(['watchlist:list', 'watchlist:item'])]
private ?\DateTimeImmutable $createdAt = null;
public function __construct()
{
$this->token = Uuid::v4();
$this->domains = new ArrayCollection();
$this->watchListTriggers = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable('now');
}
public function getToken(): ?string
@@ -186,4 +195,28 @@ class WatchList
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
}