migrations/Version20220530072614.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20220530072614 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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');
  19.         $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');
  20.         $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');
  21.         $this->addSql('ALTER TABLE category_product ADD CONSTRAINT FK_149244D312469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE category_product ADD CONSTRAINT FK_149244D34584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
  23.         $this->addSql('ALTER TABLE menu_product ADD CONSTRAINT FK_5B911913CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE menu_product ADD CONSTRAINT FK_5B9119134584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE product_option ADD CONSTRAINT FK_38FA41144584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
  26.         $this->addSql('ALTER TABLE product_option ADD CONSTRAINT FK_38FA4114A7C41D6F FOREIGN KEY (option_id) REFERENCES `option` (id) ON DELETE CASCADE');
  27.         $this->addSql('DROP TABLE menu_shop_mode');
  28.         $this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C112469DE2');
  29.         $this->addSql('DROP INDEX IDX_64C19C112469DE2 ON category');
  30.         $this->addSql('ALTER TABLE category ADD status TINYINT(1) NOT NULL, CHANGE category_id parent_id INT DEFAULT NULL');
  31.         $this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C1727ACA70 FOREIGN KEY (parent_id) REFERENCES category (id)');
  32.         $this->addSql('CREATE INDEX IDX_64C19C1727ACA70 ON category (parent_id)');
  33.         $this->addSql('ALTER TABLE menu DROP price');
  34.         $this->addSql('ALTER TABLE `option` DROP FOREIGN KEY FK_5A8600B04584665A');
  35.         $this->addSql('DROP INDEX IDX_5A8600B04584665A ON `option`');
  36.         $this->addSql('ALTER TABLE `option` DROP product_id, CHANGE status status TINYINT(1) NOT NULL');
  37.         $this->addSql('ALTER TABLE option_variant DROP FOREIGN KEY FK_E9B7A8D83472C456');
  38.         $this->addSql('DROP INDEX IDX_E9B7A8D83472C456 ON option_variant');
  39.         $this->addSql('ALTER TABLE option_variant ADD option__id INT DEFAULT NULL, DROP option_category_id, DROP taxe');
  40.         $this->addSql('ALTER TABLE option_variant ADD CONSTRAINT FK_E9B7A8D8D03F1577 FOREIGN KEY (option__id) REFERENCES `option` (id)');
  41.         $this->addSql('CREATE INDEX IDX_E9B7A8D8D03F1577 ON option_variant (option__id)');
  42.         $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD12469DE2');
  43.         $this->addSql('DROP INDEX IDX_D34A04AD12469DE2 ON product');
  44.         $this->addSql('ALTER TABLE product DROP category_id');
  45.         $this->addSql('ALTER TABLE shop_settings CHANGE time_slot_blocking_type time_slot_blocking_type ENUM(\'product\',\'order\')');
  46.     }
  47.     public function down(Schema $schema): void
  48.     {
  49.         // this down() migration is auto-generated, please modify it to your needs
  50.         $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 = \'\' ');
  51.         $this->addSql('ALTER TABLE menu_shop_mode ADD CONSTRAINT FK_4F78C6E474D6C560 FOREIGN KEY (shop_mode_id) REFERENCES shop_mode (id) ON DELETE CASCADE');
  52.         $this->addSql('ALTER TABLE menu_shop_mode ADD CONSTRAINT FK_4F78C6E4CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id) ON DELETE CASCADE');
  53.         $this->addSql('DROP TABLE category_product');
  54.         $this->addSql('DROP TABLE menu_product');
  55.         $this->addSql('DROP TABLE product_option');
  56.         $this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C1727ACA70');
  57.         $this->addSql('DROP INDEX IDX_64C19C1727ACA70 ON category');
  58.         $this->addSql('ALTER TABLE category DROP status, CHANGE parent_id category_id INT DEFAULT NULL');
  59.         $this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C112469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
  60.         $this->addSql('CREATE INDEX IDX_64C19C112469DE2 ON category (category_id)');
  61.         $this->addSql('ALTER TABLE menu ADD price DOUBLE PRECISION DEFAULT NULL');
  62.         $this->addSql('ALTER TABLE `option` ADD product_id INT DEFAULT NULL, CHANGE status status VARCHAR(255) NOT NULL');
  63.         $this->addSql('ALTER TABLE `option` ADD CONSTRAINT FK_5A8600B04584665A FOREIGN KEY (product_id) REFERENCES product (id)');
  64.         $this->addSql('CREATE INDEX IDX_5A8600B04584665A ON `option` (product_id)');
  65.         $this->addSql('ALTER TABLE `option_variant` DROP FOREIGN KEY FK_E9B7A8D8D03F1577');
  66.         $this->addSql('DROP INDEX IDX_E9B7A8D8D03F1577 ON `option_variant`');
  67.         $this->addSql('ALTER TABLE `option_variant` ADD option_category_id INT NOT NULL, ADD taxe DOUBLE PRECISION DEFAULT NULL, DROP option__id');
  68.         $this->addSql('ALTER TABLE `option_variant` ADD CONSTRAINT FK_E9B7A8D83472C456 FOREIGN KEY (option_category_id) REFERENCES `option` (id)');
  69.         $this->addSql('CREATE INDEX IDX_E9B7A8D83472C456 ON `option_variant` (option_category_id)');
  70.         $this->addSql('ALTER TABLE product ADD category_id INT DEFAULT NULL');
  71.         $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD12469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
  72.         $this->addSql('CREATE INDEX IDX_D34A04AD12469DE2 ON product (category_id)');
  73.         $this->addSql('ALTER TABLE shop_settings CHANGE time_slot_blocking_type time_slot_blocking_type VARCHAR(255) DEFAULT NULL');
  74.     }
  75. }