diff --git a/migrations/Version20240724201612.php b/migrations/Version20240724201612.php new file mode 100644 index 0000000..d022afa --- /dev/null +++ b/migrations/Version20240724201612.php @@ -0,0 +1,45 @@ +addSql('CREATE TEMPORARY TABLE __temp__tld AS SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM tld'); + $this->addSql('DROP TABLE tld'); + $this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, contract_terminated BOOLEAN DEFAULT NULL, date_of_contract_signature DATE DEFAULT NULL --(DC2Type:date_immutable) + , delegation_date DATE DEFAULT NULL --(DC2Type:date_immutable) + , registry_operator VARCHAR(255) DEFAULT NULL, removal_date DATE DEFAULT NULL --(DC2Type:date_immutable) + , specification13 BOOLEAN DEFAULT NULL, type VARCHAR(10) NOT NULL, PRIMARY KEY(tld))'); + $this->addSql('INSERT INTO tld (tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type) SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM __temp__tld'); + $this->addSql('DROP TABLE __temp__tld'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TEMPORARY TABLE __temp__tld AS SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM tld'); + $this->addSql('DROP TABLE tld'); + $this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, contract_terminated BOOLEAN DEFAULT NULL, date_of_contract_signature DATE DEFAULT NULL --(DC2Type:date_immutable) + , delegation_date DATE DEFAULT NULL --(DC2Type:date_immutable) + , registry_operator VARCHAR(255) DEFAULT NULL, removal_date DATE DEFAULT NULL --(DC2Type:date_immutable) + , specification13 BOOLEAN DEFAULT NULL, type VARCHAR(10) DEFAULT NULL, PRIMARY KEY(tld))'); + $this->addSql('INSERT INTO tld (tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type) SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM __temp__tld'); + $this->addSql('DROP TABLE __temp__tld'); + } +} diff --git a/src/Entity/Tld.php b/src/Entity/Tld.php index 5a03760..773c4ea 100644 --- a/src/Entity/Tld.php +++ b/src/Entity/Tld.php @@ -68,7 +68,7 @@ class Tld #[Groups(["tld:list", "tld:item"])] private ?bool $specification13 = null; - #[ORM\Column(length: 10, nullable: true, enumType: TldType::class)] + #[ORM\Column(length: 10, enumType: TldType::class)] #[Groups(["tld:item"])] private ?TldType $type = null; diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index b2d5f85..1a92ef4 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -339,15 +339,13 @@ readonly class RDAPService $tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]); if ($tldEntity === null) $tldEntity = new Tld(); - if ($tldEntity->getType() === null) { - $type = $this->getTldType($tld); - if ($type !== null) { - $tldEntity->setType($type); - } elseif ($tldEntity->isContractTerminated() === null) { - $tldEntity->setType(TldType::ccTLD); - } else { - $tldEntity->setType(TldType::gTLD); - } + $type = $this->getTldType($tld); + if ($type !== null) { + $tldEntity->setType($type); + } elseif ($tldEntity->isContractTerminated() === null) { + $tldEntity->setType(TldType::ccTLD); + } else { + $tldEntity->setType(TldType::gTLD); } $this->em->persist($tldEntity);