From a7c70a287f79e107063418263b3810f5c3859bb5 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 26 Sep 2024 12:48:50 +0200 Subject: [PATCH] refs #723. Delete attribute position --- migrations/Version20240926104532.php | 37 +++++++++++++++++++++++++++ src/Dto/Input/CommandGroupInput.php | 10 -------- src/Dto/Output/CommandGroupOutput.php | 4 --- src/Entity/CommandGroup.php | 15 ----------- 4 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 migrations/Version20240926104532.php diff --git a/migrations/Version20240926104532.php b/migrations/Version20240926104532.php new file mode 100644 index 0000000..62d220e --- /dev/null +++ b/migrations/Version20240926104532.php @@ -0,0 +1,37 @@ +addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2DC56641EE'); + $this->addSql('ALTER TABLE command_group DROP position'); + $this->addSql('DROP INDEX IDX_749AEB2DC56641EE ON organizational_unit'); + $this->addSql('ALTER TABLE organizational_unit DROP remote_calendar_id'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE organizational_unit ADD remote_calendar_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2DC56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)'); + $this->addSql('CREATE INDEX IDX_749AEB2DC56641EE ON organizational_unit (remote_calendar_id)'); + $this->addSql('ALTER TABLE command_group ADD position INT NOT NULL'); + } +} diff --git a/src/Dto/Input/CommandGroupInput.php b/src/Dto/Input/CommandGroupInput.php index 2a3fe64..502467c 100644 --- a/src/Dto/Input/CommandGroupInput.php +++ b/src/Dto/Input/CommandGroupInput.php @@ -30,14 +30,6 @@ final class CommandGroupInput )] public array $commands = []; - #[Assert\NotBlank(message: 'validators.command_group.position.not_blank')] - #[Groups(['command-group:write'])] - #[ApiProperty( - description: 'La posición del grupo de comandos', - example: '1', - )] - public ?int $position = null; - #[Groups(['command-group:write'])] #[ApiProperty( description: '¿Está habilitado el grupo de comandos?', @@ -59,7 +51,6 @@ final class CommandGroupInput } } - $this->position = $commandGroup->getPosition(); $this->enabled = $commandGroup->isEnabled(); } @@ -76,7 +67,6 @@ final class CommandGroupInput } $commandGroup->setCommands( $commandsToAdd ?? [] ); - $commandGroup->setPosition($this->position); return $commandGroup; } diff --git a/src/Dto/Output/CommandGroupOutput.php b/src/Dto/Output/CommandGroupOutput.php index 8e6b645..617bf79 100644 --- a/src/Dto/Output/CommandGroupOutput.php +++ b/src/Dto/Output/CommandGroupOutput.php @@ -16,9 +16,6 @@ final class CommandGroupOutput extends AbstractOutput #[Groups(['command-group:read', 'command-task:read'])] public array $commands = []; - #[Groups(['command-group:read', 'command-task:read'])] - public ?int $position = null; - #[Groups(['command-group:read'])] public \DateTime $createdAt; @@ -35,7 +32,6 @@ final class CommandGroupOutput extends AbstractOutput fn(Command $command) => new CommandOutput($command) )->toArray(); - $this->position = $commandGroup->getPosition(); $this->createdAt = $commandGroup->getCreatedAt(); $this->createdBy = $commandGroup->getCreatedBy(); } diff --git a/src/Entity/CommandGroup.php b/src/Entity/CommandGroup.php index c50bc82..90bec8e 100644 --- a/src/Entity/CommandGroup.php +++ b/src/Entity/CommandGroup.php @@ -19,9 +19,6 @@ class CommandGroup extends AbstractEntity #[ORM\ManyToMany(targetEntity: Command::class, inversedBy: 'commandGroups')] private Collection $commands; - #[ORM\Column] - private ?int $position = null; - /** * @var Collection */ @@ -70,18 +67,6 @@ class CommandGroup extends AbstractEntity return $this; } - public function getPosition(): ?int - { - return $this->position; - } - - public function setPosition(int $position): static - { - $this->position = $position; - - return $this; - } - /** * @return Collection */