app/DoctrineMigrations/Version20260205000000.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_csvに顧客のスラックス総丈フィールドを追加するマイグレーション
  8.  */
  9. final class Version20260205000000 extends AbstractMigration
  10. {
  11.     const NAME 'dtb_csv';
  12.     public function getDescription(): string
  13.     {
  14.         return 'Add slacks_soutake CSV field for Customer';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         // 受注CSV(csv_type_id = 3)にスラックス総丈を追加
  19.         $exist $this->connection->fetchOne(
  20.             "SELECT COUNT(*) FROM dtb_csv WHERE csv_type_id = 3 AND entity_name = ? AND field_name = 'dr43' AND disp_name = 'スラックス総丈'",
  21.             ['Eccube\\Entity\\Customer']
  22.         );
  23.         if ($exist == 0) {
  24.             $this->addSql("INSERT INTO dtb_csv (csv_type_id, creator_id, entity_name, field_name, disp_name, sort_no, enabled, create_date, update_date, discriminator_type) VALUES (3, 1, 'Eccube\\\\Entity\\\\Customer', 'dr43', 'スラックス総丈', 1005, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'csv')");
  25.         }
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // ロールバック時は追加したCSV項目を削除
  30.         $this->addSql("DELETE FROM dtb_csv WHERE csv_type_id = 3 AND entity_name = 'Eccube\\\\Entity\\\\Customer' AND field_name = 'dr43' AND disp_name = 'スラックス総丈'");
  31.     }
  32. }