mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
chore: rename table columns
This commit is contained in:
parent
10e573e483
commit
acc3a4550a
54
migrations/Version20250910201456.php
Normal file
54
migrations/Version20250910201456.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?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 Version20250910201456 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Rename IANA columns';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE entity ADD iana_registrar_name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD iana_rdap_base_url VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD iana_status VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD iana_updated DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD iana_date DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity DROP registrar_name_iana');
|
||||
$this->addSql('ALTER TABLE entity DROP rdap_base_url_iana');
|
||||
$this->addSql('ALTER TABLE entity DROP status_iana');
|
||||
$this->addSql('ALTER TABLE entity DROP updated_iana');
|
||||
$this->addSql('ALTER TABLE entity DROP date_iana');
|
||||
$this->addSql('COMMENT ON COLUMN entity.iana_updated IS \'(DC2Type:date_immutable)\'');
|
||||
$this->addSql('COMMENT ON COLUMN entity.iana_date IS \'(DC2Type:date_immutable)\'');
|
||||
}
|
||||
|
||||
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 entity ADD registrar_name_iana VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD rdap_base_url_iana VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD status_iana VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD updated_iana DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity ADD date_iana DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE entity DROP iana_registrar_name');
|
||||
$this->addSql('ALTER TABLE entity DROP iana_rdap_base_url');
|
||||
$this->addSql('ALTER TABLE entity DROP iana_status');
|
||||
$this->addSql('ALTER TABLE entity DROP iana_updated');
|
||||
$this->addSql('ALTER TABLE entity DROP iana_date');
|
||||
$this->addSql('COMMENT ON COLUMN entity.updated_iana IS \'(DC2Type:date_immutable)\'');
|
||||
$this->addSql('COMMENT ON COLUMN entity.date_iana IS \'(DC2Type:date_immutable)\'');
|
||||
}
|
||||
}
|
||||
@ -3,13 +3,11 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Config\RegistrarStatus;
|
||||
use App\Repository\EntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\Embedded;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
|
||||
@ -88,23 +86,8 @@ class Entity
|
||||
#[Groups(['entity:item', 'domain:item'])]
|
||||
private ?array $remarks = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['entity:item', 'domain:item'])]
|
||||
private ?string $registrarNameIANA = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['entity:item', 'domain:item'])]
|
||||
private ?string $rdapBaseUrlIANA = null;
|
||||
|
||||
#[ORM\Column(nullable: true, enumType: RegistrarStatus::class)]
|
||||
#[Groups(['entity:item', 'domain:item'])]
|
||||
private ?RegistrarStatus $statusIANA = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $updatedIANA = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $dateIANA = null;
|
||||
#[Embedded(class: IanaAccreditation::class, columnPrefix: 'iana_')]
|
||||
private ?IanaAccreditation $ianaAccreditation;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -263,63 +246,13 @@ class Entity
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRegistrarNameIANA(): ?string
|
||||
public function getIanaAccreditation(): ?IanaAccreditation
|
||||
{
|
||||
return $this->registrarNameIANA;
|
||||
return $this->ianaAccreditation;
|
||||
}
|
||||
|
||||
public function setRegistrarNameIANA(?string $registrarNameIANA): static
|
||||
public function setIanaAccreditation(?IanaAccreditation $ianaAccreditation): void
|
||||
{
|
||||
$this->registrarNameIANA = $registrarNameIANA;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRdapBaseUrlIANA(): ?string
|
||||
{
|
||||
return $this->rdapBaseUrlIANA;
|
||||
}
|
||||
|
||||
public function setRdapBaseUrlIANA(?string $rdapBaseUrlIANA): static
|
||||
{
|
||||
$this->rdapBaseUrlIANA = $rdapBaseUrlIANA;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatusIANA(): ?RegistrarStatus
|
||||
{
|
||||
return $this->statusIANA;
|
||||
}
|
||||
|
||||
public function setStatusIANA(?RegistrarStatus $statusIANA): static
|
||||
{
|
||||
$this->statusIANA = $statusIANA;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedIANA(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedIANA;
|
||||
}
|
||||
|
||||
public function setUpdatedIANA(?\DateTimeImmutable $updatedIANA): static
|
||||
{
|
||||
$this->updatedIANA = $updatedIANA;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateIANA(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateIANA;
|
||||
}
|
||||
|
||||
public function setDateIANA(?\DateTimeImmutable $dateIANA): static
|
||||
{
|
||||
$this->dateIANA = $dateIANA;
|
||||
|
||||
return $this;
|
||||
$this->ianaAccreditation = $ianaAccreditation;
|
||||
}
|
||||
}
|
||||
|
||||
87
src/Entity/IanaAccreditation.php
Normal file
87
src/Entity/IanaAccreditation.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Config\RegistrarStatus;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\Embeddable;
|
||||
|
||||
#[Embeddable]
|
||||
class IanaAccreditation
|
||||
{
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $registrarName = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $rdapBaseUrl = null;
|
||||
|
||||
#[ORM\Column(nullable: true, enumType: RegistrarStatus::class)]
|
||||
private ?RegistrarStatus $status = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $updated = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $date = null;
|
||||
|
||||
public function getRegistrarName(): ?string
|
||||
{
|
||||
return $this->registrarName;
|
||||
}
|
||||
|
||||
public function setRegistrarName(?string $registrarName): static
|
||||
{
|
||||
$this->registrarName = $registrarName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRdapBaseUrl(): ?string
|
||||
{
|
||||
return $this->rdapBaseUrl;
|
||||
}
|
||||
|
||||
public function setRdapBaseUrl(?string $rdapBaseUrl): static
|
||||
{
|
||||
$this->rdapBaseUrl = $rdapBaseUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): ?RegistrarStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(?RegistrarStatus $status): static
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdated(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
public function setUpdated(?\DateTimeImmutable $updated): static
|
||||
{
|
||||
$this->updated = $updated;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(?\DateTimeImmutable $date): static
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,7 @@ use App\Entity\DomainEvent;
|
||||
use App\Entity\DomainStatus;
|
||||
use App\Entity\Entity;
|
||||
use App\Entity\EntityEvent;
|
||||
use App\Entity\IanaAccreditation;
|
||||
use App\Entity\Nameserver;
|
||||
use App\Entity\NameserverEntity;
|
||||
use App\Entity\RdapServer;
|
||||
@ -567,11 +568,11 @@ readonly class RDAPService
|
||||
|
||||
$entity->setHandle($rdapEntity['handle']);
|
||||
|
||||
if (isset($rdapEntity['remarks']) && is_array($rdapEntity['remarks']) && null === $entity->getStatusIANA()) {
|
||||
if (isset($rdapEntity['remarks']) && is_array($rdapEntity['remarks']) && null === $entity->getIanaAccreditation()) {
|
||||
$entity->setRemarks($rdapEntity['remarks']);
|
||||
}
|
||||
|
||||
if (isset($rdapEntity['vcardArray']) && null === $entity->getStatusIANA()) {
|
||||
if (isset($rdapEntity['vcardArray']) && null === $entity->getIanaAccreditation()) {
|
||||
if (empty($entity->getJCard())) {
|
||||
if (!array_key_exists('elements', $rdapEntity['vcardArray'])) {
|
||||
$entity->setJCard($rdapEntity['vcardArray']);
|
||||
@ -605,7 +606,7 @@ readonly class RDAPService
|
||||
}
|
||||
}
|
||||
|
||||
if ($isIANAid || !isset($rdapEntity['events']) || null !== $entity->getStatusIANA()) {
|
||||
if ($isIANAid || !isset($rdapEntity['events']) || null !== $entity->getIanaAccreditation()) {
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -822,15 +823,21 @@ readonly class RDAPService
|
||||
$entity = new Entity();
|
||||
}
|
||||
$entity
|
||||
->setHandle(strval($registrar->value))->setTld(null)
|
||||
->setRegistrarNameIANA(strval($registrar->name))
|
||||
->setStatusIANA(RegistrarStatus::from(strval($registrar->status)))
|
||||
->setRdapBaseUrlIANA($registrar->rdapurl->count() ? strval($registrar->rdapurl->server) : null)
|
||||
->setUpdatedIANA(null !== $registrar->attributes()->updated ? new \DateTimeImmutable(strval($registrar->attributes()->updated)) : null)
|
||||
->setDateIANA(null !== $registrar->attributes()->date ? new \DateTimeImmutable(strval($registrar->attributes()->date)) : null)
|
||||
->setJCard(['vcard', [['version', [], 'text', '4.0'], ['fn', [], 'text', $entity->getRegistrarNameIANA()]]])
|
||||
->setHandle($registrar->value)
|
||||
->setTld(null)
|
||||
->setJCard(['vcard', [['version', [], 'text', '4.0'], ['fn', [], 'text', $registrar->name]]])
|
||||
->setRemarks(null);
|
||||
|
||||
if (null === $entity->getIanaAccreditation()) {
|
||||
$entity->setIanaAccreditation(new IanaAccreditation());
|
||||
}
|
||||
$entity->getIanaAccreditation()
|
||||
->setRegistrarName($registrar->name)
|
||||
->setStatus(RegistrarStatus::from($registrar->status))
|
||||
->setRdapBaseUrl($registrar->rdapurl->count() ? ($registrar->rdapurl->server) : null)
|
||||
->setUpdated(null !== $registrar->attributes()->updated ? new \DateTimeImmutable($registrar->attributes()->updated) : null)
|
||||
->setDate(null !== $registrar->attributes()->date ? new \DateTimeImmutable($registrar->attributes()->date) : null);
|
||||
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
$this->em->flush();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user