fix: update table scheme

This commit is contained in:
Maël Gangloff
2024-07-13 15:52:52 +02:00
parent 5faa6489b1
commit 69dc301257
9 changed files with 71 additions and 96 deletions

View File

@@ -45,7 +45,7 @@ class Domain
*/
#[ORM\ManyToMany(targetEntity: Nameserver::class, inversedBy: 'domains', cascade: ['persist'])]
#[ORM\JoinTable(name: 'domain_nameservers',
joinColumns: [new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle')],
joinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'nameserver_ldh_name', referencedColumnName: 'ldh_name')]
)]
private Collection $nameservers;

View File

@@ -17,7 +17,7 @@ class DomainEntity
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Entity::class, cascade: ['persist'], inversedBy: 'domainEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
private ?Entity $entity = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]

View File

@@ -10,10 +10,19 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: EntityRepository::class)]
class Entity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $handle = null;
#[ORM\Column(length: 255)]
private ?string $tld = null;
/**
* @var Collection<int, DomainEntity>
*/
@@ -42,6 +51,11 @@ class Entity
$this->events = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getHandle(): ?string
{
return $this->handle;
@@ -54,6 +68,18 @@ class Entity
return $this;
}
public function getTld(): ?string
{
return $this->tld;
}
public function setTld(string $tld): static
{
$this->tld = $tld;
return $this;
}
/**
* @return Collection<int, DomainEntity>
*/

View File

@@ -10,10 +10,11 @@ class EntityEvent extends Event
{
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'events')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
private ?Entity $entity = null;
public function getEntity(): ?Entity
{
return $this->entity;

View File

@@ -15,9 +15,6 @@ class Nameserver
#[ORM\Column(length: 255)]
private ?string $ldhName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $handle = null;
/**
* @var Collection<int, NameserverEntity>
*/
@@ -48,18 +45,6 @@ class Nameserver
return $this;
}
public function getHandle(): ?string
{
return $this->handle;
}
public function setHandle(string $handle): static
{
$this->handle = $handle;
return $this;
}
/**
* @return Collection<int, NameserverEntity>
*/

View File

@@ -18,9 +18,10 @@ class NameserverEntity
#[ORM\Id]
#[ORM\ManyToOne(targetEntity: Entity::class, cascade: ['persist'], inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
private ?Entity $entity = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]
private array $roles = [];