mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add createdAt to Connector and Watchlist
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
39
migrations/Version20240802232844.php
Normal file
39
migrations/Version20240802232844.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user