app/DoctrineMigrations/Version20240427024741.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 Version20240427024741 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $count $this->connection->fetchOne("SELECT COUNT(*) FROM dtb_page WHERE url = 'faq'");
  18.         if ($count 0) {
  19.             return;
  20.         }
  21.         $pageId $this->connection->fetchOne('SELECT MAX(id) FROM dtb_page');
  22.         $sortNo $this->connection->fetchOne('SELECT MAX(sort_no) FROM dtb_page_layout');
  23.         // よくいただくご質問
  24.         $pageId++;
  25.         $this->addSql("INSERT INTO dtb_page (
  26.             id, master_page_id, page_name, url, file_name, edit_type, create_date, update_date, meta_robots, discriminator_type
  27.         ) VALUES(
  28.             $pageId, NULL, 'よくいただくご質問', 'faq', 'Faq/index', 2, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'page'
  29.         )");
  30.         $sortNo++;
  31.         $this->addSql("INSERT INTO dtb_page_layout (page_id, layout_id, sort_no, discriminator_type) VALUES ($pageId, 2, $sortNo, 'pagelayout')");
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         // this down() migration is auto-generated, please modify it to your needs
  36.     }
  37. }