app/DoctrineMigrations/Version20251113142838.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of EC-CUBE
  5.  *
  6.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  7.  *
  8.  * http://www.ec-cube.co.jp/
  9.  *
  10.  * For the full copyright and license information, please view the LICENSE
  11.  * file that was distributed with this source code.
  12.  */
  13. namespace DoctrineMigrations;
  14. use Doctrine\DBAL\Schema\Schema;
  15. use Doctrine\Migrations\AbstractMigration;
  16. /**
  17.  * Add comment_detail and product_details_info columns to dtb_product table
  18.  */
  19. final class Version20251113142838 extends AbstractMigration
  20. {
  21.     public function up(Schema $schema): void
  22.     {
  23.         // Check if column already exists
  24.         $table $schema->getTable('dtb_product');
  25.         if (!$table->hasColumn('comment_detail')) {
  26.             $this->addSql("ALTER TABLE dtb_product ADD comment_detail TEXT DEFAULT NULL");
  27.         }
  28.         if (!$table->hasColumn('product_details_info')) {
  29.             $this->addSql("ALTER TABLE dtb_product ADD product_details_info TEXT DEFAULT NULL");
  30.         }
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.         // Remove column if exists
  35.         $table $schema->getTable('dtb_product');
  36.         if ($table->hasColumn('product_details_info')) {
  37.             $this->addSql("ALTER TABLE dtb_product DROP COLUMN product_details_info");
  38.         }
  39.         if ($table->hasColumn('comment_detail')) {
  40.             $this->addSql("ALTER TABLE dtb_product DROP COLUMN comment_detail");
  41.         }
  42.     }
  43. }