<?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 Version20241030214639 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add products and type attribute to product and set all existing products type to "product"';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE product_menu_product (menu INT NOT NULL, product INT NOT NULL, INDEX IDX_9FEB1FCC7D053A93 (menu), INDEX IDX_9FEB1FCCD34A04AD (product), PRIMARY KEY(menu, product)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE product_menu_product ADD CONSTRAINT FK_9FEB1FCC7D053A93 FOREIGN KEY (menu) REFERENCES product (id)');
$this->addSql('ALTER TABLE product_menu_product ADD CONSTRAINT FK_9FEB1FCCD34A04AD FOREIGN KEY (product) REFERENCES product (id)');
$this->addSql('ALTER TABLE product ADD type ENUM(\'product\',\'menu\') DEFAULT \'product\'');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE product_menu_product DROP FOREIGN KEY FK_9FEB1FCC7D053A93');
$this->addSql('ALTER TABLE product_menu_product DROP FOREIGN KEY FK_9FEB1FCCD34A04AD');
$this->addSql('DROP TABLE product_menu_product');
$this->addSql('ALTER TABLE product DROP type');
}
}