<?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 Version20220530072614 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
$this->addSql('CREATE TABLE category_product (category_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_149244D312469DE2 (category_id), INDEX IDX_149244D34584665A (product_id), PRIMARY KEY(category_id, product_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE menu_product (menu_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_5B911913CCD7E912 (menu_id), INDEX IDX_5B9119134584665A (product_id), PRIMARY KEY(menu_id, product_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product_option (product_id INT NOT NULL, option_id INT NOT NULL, INDEX IDX_38FA41144584665A (product_id), INDEX IDX_38FA4114A7C41D6F (option_id), PRIMARY KEY(product_id, option_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE category_product ADD CONSTRAINT FK_149244D312469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE category_product ADD CONSTRAINT FK_149244D34584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE menu_product ADD CONSTRAINT FK_5B911913CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE menu_product ADD CONSTRAINT FK_5B9119134584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE product_option ADD CONSTRAINT FK_38FA41144584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE product_option ADD CONSTRAINT FK_38FA4114A7C41D6F FOREIGN KEY (option_id) REFERENCES `option` (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE menu_shop_mode');
$this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C112469DE2');
$this->addSql('DROP INDEX IDX_64C19C112469DE2 ON category');
$this->addSql('ALTER TABLE category ADD status TINYINT(1) NOT NULL, CHANGE category_id parent_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C1727ACA70 FOREIGN KEY (parent_id) REFERENCES category (id)');
$this->addSql('CREATE INDEX IDX_64C19C1727ACA70 ON category (parent_id)');
$this->addSql('ALTER TABLE menu DROP price');
$this->addSql('ALTER TABLE `option` DROP FOREIGN KEY FK_5A8600B04584665A');
$this->addSql('DROP INDEX IDX_5A8600B04584665A ON `option`');
$this->addSql('ALTER TABLE `option` DROP product_id, CHANGE status status TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE option_variant DROP FOREIGN KEY FK_E9B7A8D83472C456');
$this->addSql('DROP INDEX IDX_E9B7A8D83472C456 ON option_variant');
$this->addSql('ALTER TABLE option_variant ADD option__id INT DEFAULT NULL, DROP option_category_id, DROP taxe');
$this->addSql('ALTER TABLE option_variant ADD CONSTRAINT FK_E9B7A8D8D03F1577 FOREIGN KEY (option__id) REFERENCES `option` (id)');
$this->addSql('CREATE INDEX IDX_E9B7A8D8D03F1577 ON option_variant (option__id)');
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD12469DE2');
$this->addSql('DROP INDEX IDX_D34A04AD12469DE2 ON product');
$this->addSql('ALTER TABLE product DROP category_id');
$this->addSql('ALTER TABLE shop_settings CHANGE time_slot_blocking_type time_slot_blocking_type ENUM(\'product\',\'order\')');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE menu_shop_mode (menu_id INT NOT NULL, shop_mode_id INT NOT NULL, INDEX IDX_4F78C6E4CCD7E912 (menu_id), INDEX IDX_4F78C6E474D6C560 (shop_mode_id), PRIMARY KEY(menu_id, shop_mode_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE menu_shop_mode ADD CONSTRAINT FK_4F78C6E474D6C560 FOREIGN KEY (shop_mode_id) REFERENCES shop_mode (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE menu_shop_mode ADD CONSTRAINT FK_4F78C6E4CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE category_product');
$this->addSql('DROP TABLE menu_product');
$this->addSql('DROP TABLE product_option');
$this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C1727ACA70');
$this->addSql('DROP INDEX IDX_64C19C1727ACA70 ON category');
$this->addSql('ALTER TABLE category DROP status, CHANGE parent_id category_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C112469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
$this->addSql('CREATE INDEX IDX_64C19C112469DE2 ON category (category_id)');
$this->addSql('ALTER TABLE menu ADD price DOUBLE PRECISION DEFAULT NULL');
$this->addSql('ALTER TABLE `option` ADD product_id INT DEFAULT NULL, CHANGE status status VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE `option` ADD CONSTRAINT FK_5A8600B04584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('CREATE INDEX IDX_5A8600B04584665A ON `option` (product_id)');
$this->addSql('ALTER TABLE `option_variant` DROP FOREIGN KEY FK_E9B7A8D8D03F1577');
$this->addSql('DROP INDEX IDX_E9B7A8D8D03F1577 ON `option_variant`');
$this->addSql('ALTER TABLE `option_variant` ADD option_category_id INT NOT NULL, ADD taxe DOUBLE PRECISION DEFAULT NULL, DROP option__id');
$this->addSql('ALTER TABLE `option_variant` ADD CONSTRAINT FK_E9B7A8D83472C456 FOREIGN KEY (option_category_id) REFERENCES `option` (id)');
$this->addSql('CREATE INDEX IDX_E9B7A8D83472C456 ON `option_variant` (option_category_id)');
$this->addSql('ALTER TABLE product ADD category_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD12469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
$this->addSql('CREATE INDEX IDX_D34A04AD12469DE2 ON product (category_id)');
$this->addSql('ALTER TABLE shop_settings CHANGE time_slot_blocking_type time_slot_blocking_type VARCHAR(255) DEFAULT NULL');
}
}