<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* dtb_productテーブルの各種フラグカラムのNULL値を修正
*/
final class Version20251119161129 extends AbstractMigration
{
public function getDescription(): string
{
return 'dtb_productテーブルのsales_period_flg, ship_free_flg, no_returnカラムのNULL値をデフォルト値に修正';
}
public function up(Schema $schema): void
{
// sales_period_flgのNULL値を0に設定
$this->addSql("UPDATE dtb_product SET sales_period_flg = 0 WHERE sales_period_flg IS NULL");
// ship_free_flgのNULL値を0に設定
$this->addSql("UPDATE dtb_product SET ship_free_flg = 0 WHERE ship_free_flg IS NULL");
// no_returnのNULL値を0に設定
$this->addSql("UPDATE dtb_product SET no_return = 0 WHERE no_return IS NULL");
}
public function down(Schema $schema): void
{
// このマイグレーションはデータクリーニングのため、ロールバックは不要
// NULL値に戻すことは望ましくない
}
}