fix: update table scheme

This commit is contained in:
Maël Gangloff 2024-07-12 00:50:30 +02:00
parent a691659cca
commit d0c0c5beb3
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
7 changed files with 23 additions and 24 deletions

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240711201708 extends AbstractMigration
final class Version20240711223742 extends AbstractMigration
{
public function getDescription(): string
{
@ -22,13 +22,13 @@ final class Version20240711201708 extends AbstractMigration
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE bookmark_list (token VARCHAR(36) NOT NULL, user_id INTEGER NOT NULL, PRIMARY KEY(token), CONSTRAINT FK_A650C0C4A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_A650C0C4A76ED395 ON bookmark_list (user_id)');
$this->addSql('CREATE TABLE bookmark_lists_domains (bookmark_token VARCHAR(36) NOT NULL, domain_ldh_name VARCHAR(255) NOT NULL, domain_handle VARCHAR(255) NOT NULL, PRIMARY KEY(bookmark_token, domain_ldh_name, domain_handle), CONSTRAINT FK_C12B6400D0B0A7FC FOREIGN KEY (bookmark_token) REFERENCES bookmark_list (token) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_C12B6400AF923913FEE32C10 FOREIGN KEY (domain_ldh_name, domain_handle) REFERENCES domain (ldh_name, handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE TABLE bookmark_lists_domains (bookmark_token VARCHAR(36) NOT NULL, domain_handle VARCHAR(255) NOT NULL, PRIMARY KEY(bookmark_token, domain_handle), CONSTRAINT FK_C12B6400D0B0A7FC FOREIGN KEY (bookmark_token) REFERENCES bookmark_list (token) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_C12B6400FEE32C10 FOREIGN KEY (domain_handle) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_C12B6400D0B0A7FC ON bookmark_lists_domains (bookmark_token)');
$this->addSql('CREATE INDEX IDX_C12B6400AF923913FEE32C10 ON bookmark_lists_domains (domain_ldh_name, domain_handle)');
$this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, whois_status VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(ldh_name, handle))');
$this->addSql('CREATE TABLE domain_nameservers (domain_handle VARCHAR(255) NOT NULL, domain_ldh_name VARCHAR(255) NOT NULL, nameserver_handle VARCHAR(255) NOT NULL, PRIMARY KEY(domain_handle, domain_ldh_name, nameserver_handle), CONSTRAINT FK_B6E6B63AFEE32C10AF923913 FOREIGN KEY (domain_handle, domain_ldh_name) REFERENCES domain (handle, ldh_name) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_B6E6B63A3DC1CB05 FOREIGN KEY (nameserver_handle) REFERENCES nameserver (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_B6E6B63AFEE32C10AF923913 ON domain_nameservers (domain_handle, domain_ldh_name)');
$this->addSql('CREATE INDEX IDX_C12B6400FEE32C10 ON bookmark_lists_domains (domain_handle)');
$this->addSql('CREATE TABLE domain (handle VARCHAR(255) NOT NULL, ldh_name VARCHAR(255) NOT NULL, whois_status VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(handle))');
$this->addSql('CREATE TABLE domain_nameservers (domain_handle VARCHAR(255) NOT NULL, nameserver_handle VARCHAR(255) NOT NULL, PRIMARY KEY(domain_handle, nameserver_handle), CONSTRAINT FK_B6E6B63AFEE32C10 FOREIGN KEY (domain_handle) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_B6E6B63A3DC1CB05 FOREIGN KEY (nameserver_handle) REFERENCES nameserver (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_B6E6B63AFEE32C10 ON domain_nameservers (domain_handle)');
$this->addSql('CREATE INDEX IDX_B6E6B63A3DC1CB05 ON domain_nameservers (nameserver_handle)');
$this->addSql('CREATE TABLE domain_entity (domain_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');

View File

@ -25,7 +25,7 @@ class BookmarkList
#[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'bookmarkLists')]
#[ORM\JoinTable(name: 'bookmark_lists_domains',
joinColumns: [new ORM\JoinColumn(name: 'bookmark_token', referencedColumnName: 'token')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name'), new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle')])]
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle')])]
private Collection $domains;
public function __construct()

View File

@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: DomainRepository::class)]
class Domain
{
#[ORM\Id]
#[ORM\Column(length: 255)]
private ?string $ldhName = null;
@ -23,13 +22,13 @@ class Domain
/**
* @var Collection<int, DomainEvent>
*/
#[ORM\OneToMany(targetEntity: DomainEvent::class, mappedBy: 'domain', orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: DomainEvent::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
private Collection $events;
/**
* @var Collection<int, DomainEntity>
*/
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
private Collection $domainEntities;
#[ORM\Column(length: 255)]
@ -41,15 +40,15 @@ class Domain
/**
* @var Collection<int, BookmarkList>
*/
#[ORM\ManyToMany(targetEntity: BookmarkList::class, mappedBy: 'domains')]
#[ORM\ManyToMany(targetEntity: BookmarkList::class, mappedBy: 'domains', cascade: ['persist'])]
private Collection $bookmarkLists;
/**
* @var Collection<int, Nameserver>
*/
#[ORM\ManyToMany(targetEntity: Nameserver::class, inversedBy: 'domains')]
#[ORM\ManyToMany(targetEntity: Nameserver::class, inversedBy: 'domains', cascade: ['persist'])]
#[ORM\JoinTable(name: 'domain_nameservers',
joinColumns: [new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle'), new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')],
joinColumns: [new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'nameserver_handle', referencedColumnName: 'handle')]
)]
private Collection $nameservers;

View File

@ -11,12 +11,12 @@ use Doctrine\ORM\Mapping as ORM;
class DomainEntity
{
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Domain::class, inversedBy: 'domainEntities')]
#[ORM\ManyToOne(targetEntity: Domain::class, cascade: ['persist'], inversedBy: 'domainEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Domain $domain = null;
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'domainEntities')]
#[ORM\ManyToOne(targetEntity: Entity::class, cascade: ['persist'], inversedBy: 'domainEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;

View File

@ -27,9 +27,9 @@ class Entity
private Collection $nameserverEntities;
/**
* @var Collection<int, Event>
* @var Collection<int, EntityEvent>
*/
#[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'entity', orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: EntityEvent::class, mappedBy: 'entity', cascade: ['persist'], orphanRemoval: true)]
private Collection $events;
public function __construct()
@ -112,14 +112,14 @@ class Entity
}
/**
* @return Collection<int, Event>
* @return Collection<int, EntityEvent>
*/
public function getEvents(): Collection
{
return $this->events;
}
public function addEvent(Event $event): static
public function addEvent(EntityEvent $event): static
{
if (!$this->events->contains($event)) {
$this->events->add($event);
@ -129,7 +129,7 @@ class Entity
return $this;
}
public function removeEvent(Event $event): static
public function removeEvent(EntityEvent $event): static
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)

View File

@ -22,7 +22,7 @@ class Nameserver
/**
* @var Collection<int, NameserverEntity>
*/
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'nameserver', orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'nameserver', cascade: ['persist'], orphanRemoval: true)]
private Collection $nameserverEntities;
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]

View File

@ -12,12 +12,12 @@ use Doctrine\ORM\Mapping as ORM;
class NameserverEntity
{
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Nameserver::class, inversedBy: 'nameserverEntities')]
#[ORM\ManyToOne(targetEntity: Nameserver::class, cascade: ['persist'], inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Nameserver $nameserver = null;
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'nameserverEntities')]
#[ORM\ManyToOne(targetEntity: Entity::class, cascade: ['persist'], inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;