<?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 Version20250101042651 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
if ($schema->hasTable("mtb_genre")) {
return;
}
$this->addSql("CREATE TABLE `mtb_genre` (
`id` smallint unsigned NOT NULL,
`name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`sort_no` smallint unsigned NOT NULL,
`discriminator_type` varchar(255) COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin");
// add data table genre
$this->addSql("
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (1,'Blu-ray',1,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (2,'DVD',2,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (3,'CD',3,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (4,'DX BOX',4,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (5,'Tシャツ付',5,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (6,'グッズ',6,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (7,'書籍',7,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (8,'ワードレコーズ・ダイレクト限定',8,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (9,'チケット',9,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (10,'SALE',10,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (11,'LPセット',11,'genre');
INSERT INTO `mtb_genre` (`id`,`name`,`sort_no`,`discriminator_type`) VALUES (12,'アパレル',12,'genre');
");
// dtb_product_genre
$this->addSql("CREATE TABLE `dtb_product_genre` (
`product_id` int unsigned NOT NULL,
`genre_id` smallint unsigned NOT NULL,
`discriminator_type` varchar(255) COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`product_id`,`genre_id`),
KEY `IDX_B05778914585766B` (`product_id`),
KEY `IDX_B057789112479DF8` (`genre_id`),
CONSTRAINT `FK_B057789112479DF8` FOREIGN KEY (`genre_id`) REFERENCES `mtb_genre` (`id`),
CONSTRAINT `FK_B05778914585766B` FOREIGN KEY (`product_id`) REFERENCES `dtb_product` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("DROP TABLE mtb_genre;");
$this->addSql("DROP TABLE dtb_product_genre;");
}
}