migrations/Version20230201134409.php line 1

Open in your IDE?
  1. <?php
  2. /**
  3.  * @noinspection PhpUnused
  4.  * @noinspection PhpInternalEntityUsedInspection
  5.  */
  6. declare(strict_types=1);
  7. namespace DoctrineMigrations;
  8. use App\Validator\Constraints\Api\CoreModule\Module\AbstractModuleIdCompound;
  9. use Doctrine\DBAL\Schema\Schema;
  10. use Doctrine\Migrations\AbstractMigration;
  11. /**
  12.  * Auto-generated Migration: Please modify to your needs!
  13.  *
  14.  * @package API
  15.  * @internal
  16.  */
  17. final class Version20230201134409 extends AbstractMigration
  18. {
  19.     public function down(Schema $schema): void
  20.     {
  21.         // this down() migration is auto-generated, please modify it to your needs
  22.     }
  23.     public function getDescription(): string
  24.     {
  25.         return
  26.             "- Seeding of module table.";
  27.     }
  28.     public function up(Schema $schema): void
  29.     {
  30.         // this up() migration is auto-generated, please modify it to your needs.
  31.         // Uncomment when every module is enabled
  32. //        $list = '(\'' . implode('\'),(\'', AbstractModuleIdCompound::ENABLED_CHOICES) .
  33. //            '\');';
  34. //        $this->addSql(
  35. //            "
  36. //                INSERT INTO module
  37. //                    (id)
  38. //                VALUES
  39. //                    $list
  40. //            "
  41. //        );
  42.         // temporary migration script
  43.         $values = [];
  44.         foreach (AbstractModuleIdCompound::ACTIVE_MODULE_IDS as $moduleId => $isActive) {
  45.             $values[] = "('{$moduleId}', {$isActive})";
  46.         }
  47.         $list implode(','$values);
  48.         $this->addSql(
  49.             "
  50.                 INSERT INTO module
  51.                     (id, active)
  52.                 VALUES
  53.                     $list
  54.             "
  55.         );
  56.     }
  57. }