app/DoctrineMigrations/Version20251119163029.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.  * dtb_schoolテーブルの各種フラグカラムのNULL値を修正
  8.  */
  9. final class Version20251119163029 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'dtb_schoolテーブルのredirect_flgおよびその他のフラグカラムのNULL値をデフォルト値に修正';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // redirect_flgのNULL値を0に設定
  18.         $this->addSql("UPDATE dtb_school SET redirect_flg = 0 WHERE redirect_flg IS NULL OR redirect_flg = ''");
  19.         
  20.         // 他のフラグカラムも修正
  21.         $this->addSql("UPDATE dtb_school SET filter_visible_flag = 1 WHERE filter_visible_flag IS NULL");
  22.         $this->addSql("UPDATE dtb_school SET correct_size_menu_flag = 1 WHERE correct_size_menu_flag IS NULL");
  23.         $this->addSql("UPDATE dtb_school SET correct_size_banner_flag = 1 WHERE correct_size_banner_flag IS NULL");
  24.         $this->addSql("UPDATE dtb_school SET commitment_uniform_menu_flag = 1 WHERE commitment_uniform_menu_flag IS NULL");
  25.         $this->addSql("UPDATE dtb_school SET commitment_uniform_banner_flag = 1 WHERE commitment_uniform_banner_flag IS NULL");
  26.         $this->addSql("UPDATE dtb_school SET measurement_procedure_banner_flag = 1 WHERE measurement_procedure_banner_flag IS NULL");
  27.         $this->addSql("UPDATE dtb_school SET return_exchange_banner_flag = 1 WHERE return_exchange_banner_flag IS NULL");
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         // このマイグレーションはデータクリーニングのため、ロールバックは不要
  32.     }
  33. }