migrations/Version20240724091831DataUpdate.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Entity\ActiveServices\ProjectStatus;
  5. use App\Repository\ActiveServices\ProjectStatusRepository;
  6. use Doctrine\DBAL\Schema\Schema;
  7. use Doctrine\Migrations\AbstractMigration;
  8. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  9. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  10. /**
  11.  * Auto-generated Migration: Please modify to your needs!
  12.  */
  13. final class Version20240724091831DataUpdate extends AbstractMigration implements ContainerAwareInterface
  14. {
  15.     use ContainerAwareTrait;
  16.     public function getDescription(): string
  17.     {
  18.         return '';
  19.     }
  20.     public function up(Schema $schema): void
  21.     {
  22.         $entityManager $this->container->get('doctrine.orm.entity_manager');
  23.         /** @var ProjectStatusRepository $projectRepository */
  24.         $projectStatusRepository $entityManager->getRepository(ProjectStatus::class);
  25.         /** @var ProjectStatus $projectStatus */
  26.         foreach ($projectStatusRepository->findAll() as $projectStatus) {
  27.             if ($projectStatus->getIsEditable()) {
  28.                 $projectStatus->setName($projectStatus->getName() . '_' $projectStatus->getId());
  29.                 $entityManager->persist($projectStatus);
  30.             }
  31.         }
  32.         $entityManager->flush();
  33.     }
  34. }