<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* dtb_csvに顧客のスラックス総丈フィールドを追加するマイグレーション
*/
final class Version20260205000000 extends AbstractMigration
{
const NAME = 'dtb_csv';
public function getDescription(): string
{
return 'Add slacks_soutake CSV field for Customer';
}
public function up(Schema $schema): void
{
// 受注CSV(csv_type_id = 3)にスラックス総丈を追加
$exist = $this->connection->fetchOne(
"SELECT COUNT(*) FROM dtb_csv WHERE csv_type_id = 3 AND entity_name = ? AND field_name = 'dr43' AND disp_name = 'スラックス総丈'",
['Eccube\\Entity\\Customer']
);
if ($exist == 0) {
$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')");
}
}
public function down(Schema $schema): void
{
// ロールバック時は追加したCSV項目を削除
$this->addSql("DELETE FROM dtb_csv WHERE csv_type_id = 3 AND entity_name = 'Eccube\\\\Entity\\\\Customer' AND field_name = 'dr43' AND disp_name = 'スラックス総丈'");
}
}