diff --git a/migrations/Version20240722233219.php b/migrations/Version20240722233219.php new file mode 100644 index 0000000..e367f22 --- /dev/null +++ b/migrations/Version20240722233219.php @@ -0,0 +1,47 @@ +addSql('CREATE TEMPORARY TABLE __temp__domain AS SELECT ldh_name, tld_id, handle, status, created_at, updated_at FROM domain'); + $this->addSql('DROP TABLE domain'); + $this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, tld_id VARCHAR(63) NOT NULL, handle VARCHAR(255) DEFAULT NULL, status CLOB NOT NULL --(DC2Type:simple_array) + , created_at DATE NOT NULL --(DC2Type:date_immutable) + , updated_at DATE NOT NULL --(DC2Type:date_immutable) + , PRIMARY KEY(ldh_name), CONSTRAINT FK_A7A91E0B50F7084E FOREIGN KEY (tld_id) REFERENCES tld (tld) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO domain (ldh_name, tld_id, handle, status, created_at, updated_at) SELECT ldh_name, tld_id, handle, status, created_at, updated_at FROM __temp__domain'); + $this->addSql('DROP TABLE __temp__domain'); + $this->addSql('CREATE INDEX IDX_A7A91E0B50F7084E ON domain (tld_id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TEMPORARY TABLE __temp__domain AS SELECT ldh_name, tld_id, handle, status, created_at, updated_at FROM domain'); + $this->addSql('DROP TABLE domain'); + $this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, tld_id VARCHAR(63) NOT NULL, handle VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array) + , created_at DATE NOT NULL --(DC2Type:date_immutable) + , updated_at DATE NOT NULL --(DC2Type:date_immutable) + , PRIMARY KEY(ldh_name), CONSTRAINT FK_A7A91E0B50F7084E FOREIGN KEY (tld_id) REFERENCES tld (tld) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO domain (ldh_name, tld_id, handle, status, created_at, updated_at) SELECT ldh_name, tld_id, handle, status, created_at, updated_at FROM __temp__domain'); + $this->addSql('DROP TABLE __temp__domain'); + $this->addSql('CREATE INDEX IDX_A7A91E0B50F7084E ON domain (tld_id)'); + } +} diff --git a/src/Entity/Domain.php b/src/Entity/Domain.php index a3cf558..f75d40b 100644 --- a/src/Entity/Domain.php +++ b/src/Entity/Domain.php @@ -18,7 +18,6 @@ use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Serializer\Attribute\SerializedName; #[ORM\Entity(repositoryClass: DomainRepository::class)] -#[UniqueEntity('handle')] #[ApiResource( operations: [ new GetCollection( @@ -53,7 +52,7 @@ class Domain #[Groups(['domain:item', 'domain:list', 'watchlist:item'])] private ?string $ldhName = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] #[Groups(['domain:item', 'domain:list', 'watchlist:item'])] private ?string $handle = null; diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 6d99336..ec86254 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -91,9 +91,10 @@ readonly class RDAPService $domain ->setTld($tld) ->setLdhName($res['ldhName']) - ->setHandle($res['handle']) ->setStatus($res['status']); + if (array_key_exists('handle', $res)) $domain->setHandle($res['handle']); + foreach ($res['events'] as $rdapEvent) { $eventAction = EventAction::from($rdapEvent['eventAction']);