<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250624151014 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add fields Product.{pack, productPack}, added entity {ProductPack}';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE product_pack (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, product_related_id INT NOT NULL, quantity INT NOT NULL, INDEX IDX_1A367C824584665A (product_id), INDEX IDX_1A367C82D2059F2A (product_related_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE product_pack ADD CONSTRAINT FK_1A367C824584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE product_pack ADD CONSTRAINT FK_1A367C82D2059F2A FOREIGN KEY (product_related_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE product ADD pack TINYINT(1) DEFAULT 0 NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE product_pack DROP FOREIGN KEY FK_1A367C824584665A');
$this->addSql('ALTER TABLE product_pack DROP FOREIGN KEY FK_1A367C82D2059F2A');
$this->addSql('DROP TABLE product_pack');
$this->addSql('ALTER TABLE product DROP pack');
}
}