diff --git a/migrations/Version20240726182804.php b/migrations/Version20240726182804.php index fd5066b..48c13db 100644 --- a/migrations/Version20240726182804.php +++ b/migrations/Version20240726182804.php @@ -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'); diff --git a/migrations/Version20240727213730.php b/migrations/Version20240727213730.php index 02b56e1..2be95b0 100644 --- a/migrations/Version20240727213730.php +++ b/migrations/Version20240727213730.php @@ -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'); diff --git a/migrations/Version20240729131244.php b/migrations/Version20240729131244.php index 27295c2..a36906b 100644 --- a/migrations/Version20240729131244.php +++ b/migrations/Version20240729131244.php @@ -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'); diff --git a/migrations/Version20240730193422.php b/migrations/Version20240730193422.php index 8d6c367..f80099c 100644 --- a/migrations/Version20240730193422.php +++ b/migrations/Version20240730193422.php @@ -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'); diff --git a/migrations/Version20240802232844.php b/migrations/Version20240802232844.php new file mode 100644 index 0000000..9f2dc7f --- /dev/null +++ b/migrations/Version20240802232844.php @@ -0,0 +1,39 @@ +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'); + } +} diff --git a/src/Entity/Connector.php b/src/Entity/Connector.php index 40c0ec8..b60fbfe 100644 --- a/src/Entity/Connector.php +++ b/src/Entity/Connector.php @@ -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; + } } diff --git a/src/Entity/WatchList.php b/src/Entity/WatchList.php index 4d04f42..b4b1037 100644 --- a/src/Entity/WatchList.php +++ b/src/Entity/WatchList.php @@ -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; + } }