<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* 会員メニュー(公式LINE・年間スケジュール表・出品リスト・マニュアル)用のカラムを dtb_base_info に追加.
*
* 既にカラムが存在する環境(schema:update 済み等)ではスキップする.
*/
final class Version20261112000001 extends AbstractMigration
{
private const COLUMNS = [
'line_official_url' => 'VARCHAR(1024) DEFAULT NULL',
'annual_schedule_file' => 'VARCHAR(255) DEFAULT NULL',
'listing_list_file' => 'VARCHAR(255) DEFAULT NULL',
'manual_file' => 'VARCHAR(255) DEFAULT NULL',
];
public function getDescription(): string
{
return 'Add member menu (official LINE URL / download files) columns to dtb_base_info';
}
public function up(Schema $schema): void
{
$table = $schema->getTable('dtb_base_info');
foreach (self::COLUMNS as $name => $definition) {
if (!$table->hasColumn($name)) {
$this->addSql(sprintf('ALTER TABLE dtb_base_info ADD %s %s', $name, $definition));
}
}
}
public function down(Schema $schema): void
{
$table = $schema->getTable('dtb_base_info');
foreach (array_keys(self::COLUMNS) as $name) {
if ($table->hasColumn($name)) {
$this->addSql(sprintf('ALTER TABLE dtb_base_info DROP %s', $name));
}
}
}
}