diff --git a/migrations/Version20240710215553.php b/migrations/Version20240710215553.php deleted file mode 100644 index 5283322..0000000 --- a/migrations/Version20240710215553.php +++ /dev/null @@ -1,59 +0,0 @@ -addSql('CREATE TABLE domain (ldhname VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:array) - , whois_status VARCHAR(255) NOT NULL, PRIMARY KEY(ldhname))'); - $this->addSql('CREATE TABLE domain_entity (domain_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles VARCHAR(255) NOT NULL, PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('CREATE INDEX IDX_614B48A1115F0EE5 ON domain_entity (domain_id)'); - $this->addSql('CREATE INDEX IDX_614B48A181257D5D ON domain_entity (entity_id)'); - $this->addSql('CREATE TABLE entity (handle VARCHAR(255) NOT NULL, PRIMARY KEY(handle))'); - $this->addSql('CREATE TABLE event ("action" VARCHAR(255) NOT NULL, domain_id VARCHAR(255) NOT NULL, date DATE NOT NULL --(DC2Type:date_immutable) - , PRIMARY KEY("action", domain_id), CONSTRAINT FK_3BAE0AA7115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('CREATE INDEX IDX_3BAE0AA7115F0EE5 ON event (domain_id)'); - $this->addSql('CREATE TABLE nameserver (handle VARCHAR(255) NOT NULL, ldhname VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:array) - , PRIMARY KEY(handle))'); - $this->addSql('CREATE TABLE nameserver_entity (nameserver_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:array) - , status CLOB NOT NULL --(DC2Type:array) - , PRIMARY KEY(nameserver_id, entity_id), CONSTRAINT FK_A269AFB41A555619 FOREIGN KEY (nameserver_id) REFERENCES nameserver (handle) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_A269AFB481257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('CREATE INDEX IDX_A269AFB41A555619 ON nameserver_entity (nameserver_id)'); - $this->addSql('CREATE INDEX IDX_A269AFB481257D5D ON nameserver_entity (entity_id)'); - $this->addSql('CREATE TABLE messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) - , available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) - , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - )'); - $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)'); - $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)'); - $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE domain'); - $this->addSql('DROP TABLE domain_entity'); - $this->addSql('DROP TABLE entity'); - $this->addSql('DROP TABLE event'); - $this->addSql('DROP TABLE nameserver'); - $this->addSql('DROP TABLE nameserver_entity'); - $this->addSql('DROP TABLE messenger_messages'); - } -} diff --git a/migrations/Version20240710222838.php b/migrations/Version20240710222838.php new file mode 100644 index 0000000..0da6526 --- /dev/null +++ b/migrations/Version20240710222838.php @@ -0,0 +1,44 @@ +addSql('CREATE TEMPORARY TABLE __temp__domain_entity AS SELECT domain_id, entity_id, roles FROM domain_entity'); + $this->addSql('DROP TABLE domain_entity'); + $this->addSql('CREATE TABLE domain_entity (domain_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:array) + , PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO domain_entity (domain_id, entity_id, roles) SELECT domain_id, entity_id, roles FROM __temp__domain_entity'); + $this->addSql('DROP TABLE __temp__domain_entity'); + $this->addSql('CREATE INDEX IDX_614B48A181257D5D ON domain_entity (entity_id)'); + $this->addSql('CREATE INDEX IDX_614B48A1115F0EE5 ON domain_entity (domain_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_entity AS SELECT domain_id, entity_id, roles FROM domain_entity'); + $this->addSql('DROP TABLE domain_entity'); + $this->addSql('CREATE TABLE domain_entity (domain_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles VARCHAR(255) NOT NULL, PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO domain_entity (domain_id, entity_id, roles) SELECT domain_id, entity_id, roles FROM __temp__domain_entity'); + $this->addSql('DROP TABLE __temp__domain_entity'); + $this->addSql('CREATE INDEX IDX_614B48A1115F0EE5 ON domain_entity (domain_id)'); + $this->addSql('CREATE INDEX IDX_614B48A181257D5D ON domain_entity (entity_id)'); + } +} diff --git a/src/Entity/DomainEntity.php b/src/Entity/DomainEntity.php index 59144aa..499b0a7 100644 --- a/src/Entity/DomainEntity.php +++ b/src/Entity/DomainEntity.php @@ -3,6 +3,7 @@ namespace App\Entity; use App\Repository\DomainEntityRepository; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: DomainEntityRepository::class)] @@ -18,8 +19,8 @@ class DomainEntity #[ORM\JoinColumn(nullable: false, referencedColumnName: 'handle')] private ?Entity $entity = null; - #[ORM\Column(length: 255)] - private ?string $roles = null; + #[ORM\Column(type: Types::ARRAY)] + private array $roles = []; public function getDomain(): ?Domain { @@ -45,12 +46,12 @@ class DomainEntity return $this; } - public function getRoles(): ?string + public function getRoles(): ?array { return $this->roles; } - public function setRoles(string $roles): static + public function setRoles(array $roles): static { $this->roles = $roles;