migrations/Version20210802145745.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 Version20210802145745 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 shop_order (id INT AUTO_INCREMENT NOT NULL, order_id INT NOT NULL, unit INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE shop_order_user (shop_order_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_BA110178562797AE (shop_order_id), INDEX IDX_BA110178A76ED395 (user_id), PRIMARY KEY(shop_order_id, user_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE shop_order_shop_produit (shop_order_id INT NOT NULL, shop_produit_id INT NOT NULL, INDEX IDX_4DEC1360562797AE (shop_order_id), INDEX IDX_4DEC1360754793DD (shop_produit_id), PRIMARY KEY(shop_order_id, shop_produit_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE shop_order_user ADD CONSTRAINT FK_BA110178562797AE FOREIGN KEY (shop_order_id) REFERENCES shop_order (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE shop_order_user ADD CONSTRAINT FK_BA110178A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
  23.         $this->addSql('ALTER TABLE shop_order_shop_produit ADD CONSTRAINT FK_4DEC1360562797AE FOREIGN KEY (shop_order_id) REFERENCES shop_order (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE shop_order_shop_produit ADD CONSTRAINT FK_4DEC1360754793DD FOREIGN KEY (shop_produit_id) REFERENCES shop_produit (id) ON DELETE CASCADE');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('ALTER TABLE shop_order_user DROP FOREIGN KEY FK_BA110178562797AE');
  30.         $this->addSql('ALTER TABLE shop_order_shop_produit DROP FOREIGN KEY FK_4DEC1360562797AE');
  31.         $this->addSql('DROP TABLE shop_order');
  32.         $this->addSql('DROP TABLE shop_order_user');
  33.         $this->addSql('DROP TABLE shop_order_shop_produit');
  34.     }
  35. }