diff --git a/migrations/Version20240711223742.php b/migrations/Version20240711233813.php similarity index 88% rename from migrations/Version20240711223742.php rename to migrations/Version20240711233813.php index df1a8b4..e1c1dc6 100644 --- a/migrations/Version20240711223742.php +++ b/migrations/Version20240711233813.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20240711223742 extends AbstractMigration +final class Version20240711233813 extends AbstractMigration { public function getDescription(): string { @@ -34,12 +34,12 @@ final class Version20240711223742 extends AbstractMigration , 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)'); $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 domain_event (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, domain_id VARCHAR(255) NOT NULL, "action" VARCHAR(255) NOT NULL, date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , CONSTRAINT FK_E8D52271115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('CREATE TABLE domain_event ("action" VARCHAR(255) NOT NULL, domain_id VARCHAR(255) NOT NULL, date DATETIME NOT NULL --(DC2Type:datetime_immutable) + , PRIMARY KEY("action", domain_id), CONSTRAINT FK_E8D52271115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); $this->addSql('CREATE INDEX IDX_E8D52271115F0EE5 ON domain_event (domain_id)'); $this->addSql('CREATE TABLE entity (handle VARCHAR(255) NOT NULL, PRIMARY KEY(handle))'); - $this->addSql('CREATE TABLE entity_event (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, entity_id VARCHAR(255) NOT NULL, "action" VARCHAR(255) NOT NULL, date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , CONSTRAINT FK_975A3F5E81257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('CREATE TABLE entity_event ("action" VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, date DATETIME NOT NULL --(DC2Type:datetime_immutable) + , PRIMARY KEY("action", entity_id), CONSTRAINT FK_975A3F5E81257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)'); $this->addSql('CREATE INDEX IDX_975A3F5E81257D5D ON entity_event (entity_id)'); $this->addSql('CREATE TABLE nameserver (handle VARCHAR(255) NOT NULL, ldh_name VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array) , PRIMARY KEY(handle))'); diff --git a/src/Entity/DomainEvent.php b/src/Entity/DomainEvent.php index 5a55c6a..ced1efa 100644 --- a/src/Entity/DomainEvent.php +++ b/src/Entity/DomainEvent.php @@ -8,7 +8,8 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: DomainEventRepository::class)] class DomainEvent extends Event { - #[ORM\ManyToOne(targetEntity: Domain::class, inversedBy: 'events')] + #[ORM\Id] + #[ORM\ManyToOne(targetEntity: Domain::class, cascade: ['persist'], inversedBy: 'events')] #[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)] private ?Domain $domain = null; diff --git a/src/Entity/EntityEvent.php b/src/Entity/EntityEvent.php index 21bf1d3..f6cbb31 100644 --- a/src/Entity/EntityEvent.php +++ b/src/Entity/EntityEvent.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping as ORM; class EntityEvent extends Event { + #[ORM\Id] #[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'events')] #[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)] private ?Entity $entity = null; diff --git a/src/Entity/Event.php b/src/Entity/Event.php index 78da454..52c4ff7 100644 --- a/src/Entity/Event.php +++ b/src/Entity/Event.php @@ -10,22 +10,13 @@ use Doctrine\ORM\Mapping as ORM; class Event { #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; - #[ORM\Column(enumType: EventAction::class)] private ?EventAction $action = null; - #[ORM\Column] + #[ORM\Column(type: 'datetime_immutable')] private ?DateTimeImmutable $date = null; - public function getId(): ?int - { - return $this->id; - } - public function getAction(): ?EventAction { return $this->action;