app/DoctrineMigrations/Version20251014062000.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.  * 商品テーブルにタグID12・タグID7用のカスタムテキストフィールドを追加
  8.  *
  9.  * タグID12「予約商品」のカートページ表示用テキストと
  10.  * タグID7「取扱商品」の商品詳細ページ表示用テキストを
  11.  * 管理画面で設定できるようにするための機能追加
  12.  */
  13. final class Version20251014062000 extends AbstractMigration
  14. {
  15.     /**
  16.      * マイグレーションの説明
  17.      */
  18.     public function getDescription(): string
  19.     {
  20.         return 'Add tag12_display_text and tag7_display_text columns to dtb_product table';
  21.     }
  22.     /**
  23.      * マイグレーション実行:2つのテキストフィールドを追加
  24.      */
  25.     public function up(Schema $schema): void
  26.     {
  27.         // タグID12「予約商品」用テキストフィールドを追加
  28.         $this->addSql("
  29.             ALTER TABLE dtb_product
  30.             ADD tag12_display_text LONGTEXT DEFAULT NULL
  31.             COMMENT '予約商品用テキスト(タグID12、カートページ表示用)'
  32.         ");
  33.         // タグID7「取扱商品」用テキストフィールドを追加
  34.         $this->addSql("
  35.             ALTER TABLE dtb_product
  36.             ADD tag7_display_text LONGTEXT DEFAULT NULL
  37.             COMMENT '取扱商品用テキスト(タグID7、商品詳細ページ表示用)'
  38.         ");
  39.     }
  40.     /**
  41.      * ロールバック:2つのテキストフィールドを削除
  42.      */
  43.     public function down(Schema $schema): void
  44.     {
  45.         $this->addSql('ALTER TABLE dtb_product DROP tag12_display_text');
  46.         $this->addSql('ALTER TABLE dtb_product DROP tag7_display_text');
  47.     }
  48. }