app/DoctrineMigrations/Version20240615204253.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 Version20240615204253 extends AbstractMigration
  10. {
  11.     const pages = [
  12.         [
  13.             'name' => 'サイトマップ',
  14.             'url' => 'help_sitemap',
  15.             'file' => 'Help/sitemap',
  16.         ],
  17.         [
  18.             'name' => 'よくある質問',
  19.             'url' => 'help_qa',
  20.             'file' => 'Help/qa',
  21.         ],
  22.     ];
  23.     public function up(Schema $schema): void
  24.     {
  25.         foreach (self::pages as $page) {
  26.             $this->addSql("UPDATE dtb_page_layout SET discriminator_type = 'pagelayout' WHERE page_id = (
  27.                 SELECT id FROM dtb_page  WHERE url = '$page[url]'
  28.             )");
  29.         }
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         foreach (self::pages as $page) {
  34.             $this->addSql("UPDATE dtb_page_layout SET discriminator_type = 'page_layout' WHERE page_id = (
  35.                 SELECT id FROM dtb_page WHERE url = '$page[url]'
  36.             )");
  37.         }
  38.     }
  39. }