<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251001224506 extends AbstractMigration
{
public function getDescription(): string
{
return '関連商品設定テーブルを作成';
}
public function up(Schema $schema): void
{
// 関連商品設定テーブルを作成
$this->addSql('CREATE TABLE dtb_related_product_setting (
id INT AUTO_INCREMENT NOT NULL,
product_id INT UNSIGNED NOT NULL,
sort_no INT UNSIGNED NOT NULL,
create_date DATETIME NOT NULL,
update_date DATETIME NOT NULL,
INDEX IDX_RELATED_PRODUCT_PRODUCT_ID (product_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
// 外部キー制約を追加
$this->addSql('ALTER TABLE dtb_related_product_setting ADD CONSTRAINT FK_RELATED_PRODUCT_PRODUCT_ID FOREIGN KEY (product_id) REFERENCES dtb_product (id)');
}
public function down(Schema $schema): void
{
// テーブルを削除
$this->addSql('DROP TABLE dtb_related_product_setting');
}
}