migrations/Version20251106090800.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20251106090800 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('ALTER TABLE channel_positioning_test_blocks ADD mandatory_info TEXT DEFAULT NULL, ADD example_enabled TINYINT(1) DEFAULT 1 NOT NULL, ADD example_label VARCHAR(255) DEFAULT NULL, ADD example_description TEXT DEFAULT NULL, ADD example_answers JSON DEFAULT NULL COMMENT \'(DC2Type:json)\'');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         // this down() migration is auto-generated, please modify it to your needs
  23.         $this->addSql('ALTER TABLE channel_positioning_test_blocks DROP mandatory_info, DROP example_enabled, DROP example_label, DROP example_description, DROP example_answers');
  24.     }
  25.     public function postUp(Schema $schema): void
  26.     {
  27.         $this->connection->executeStatement(
  28.             'UPDATE `channel_positioning_test_blocks` SET mandatory_info = :text WHERE mandatory_info IS NULL',
  29.             ['text' => "Chaque question est obligatoire. Une fois validé, le formulaire n’est plus modifiable.\nVeuillez vérifier vos réponses avant toute validation."]
  30.         );
  31.         $this->connection->executeStatement(
  32.             'UPDATE `channel_positioning_test_blocks` SET example_label = :text WHERE example_label IS NULL',
  33.             ['text' => 'Quel(s) élément(s) sont nécessaires pour faire pousser une plante ?']
  34.         );
  35.         $this->connection->executeStatement(
  36.             'UPDATE `channel_positioning_test_blocks` SET example_description = :text WHERE example_description IS NULL',
  37.             ['text' => '(Plusieurs réponses possibles)']
  38.         );
  39.         $answers = [
  40.             [
  41.                 'label' => 'La lumière du soleil',
  42.                 'valid' => true,
  43.             ],
  44.             [
  45.                 'label' => 'Le Wi-Fi',
  46.                 'valid' => false,
  47.             ],
  48.             [
  49.                 'label' => 'De l\'eau',
  50.                 'valid' => true,
  51.             ],
  52.             [
  53.                 'label' => 'De la terre',
  54.                 'valid' => true,
  55.             ],
  56.         ];
  57.         $this->connection->executeStatement(
  58.             'UPDATE `channel_positioning_test_blocks` SET example_answers = :array WHERE example_answers IS NULL',
  59.             ['array' => json_encode($answers)]
  60.         );
  61.     }
  62. }