migrations/Version20200309133611.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 Version20200309133611 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE voucher_purchase (id INT AUTO_INCREMENT NOT NULL, voucher_store_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', voucher_id INT NOT NULL, to_order_id INT NOT NULL, delivery VARCHAR(255) NOT NULL, INDEX IDX_FFB089B22E35F098 (voucher_store_id), UNIQUE INDEX UNIQ_FFB089B228AA1B6F (voucher_id), UNIQUE INDEX UNIQ_FFB089B240C6F396 (to_order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE voucher_store (id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', state VARCHAR(32) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE voucher_store_campaign (voucher_store_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', campaign_id INT NOT NULL, INDEX IDX_378F187B2E35F098 (voucher_store_id), INDEX IDX_378F187BF639F774 (campaign_id), PRIMARY KEY(voucher_store_id, campaign_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('ALTER TABLE voucher_purchase ADD CONSTRAINT FK_FFB089B22E35F098 FOREIGN KEY (voucher_store_id) REFERENCES voucher_store (id)');
  23.         $this->addSql('ALTER TABLE voucher_purchase ADD CONSTRAINT FK_FFB089B228AA1B6F FOREIGN KEY (voucher_id) REFERENCES voucher (id)');
  24.         $this->addSql('ALTER TABLE voucher_purchase ADD CONSTRAINT FK_FFB089B240C6F396 FOREIGN KEY (to_order_id) REFERENCES orders (id)');
  25.         $this->addSql('ALTER TABLE voucher_store_campaign ADD CONSTRAINT FK_378F187B2E35F098 FOREIGN KEY (voucher_store_id) REFERENCES voucher_store (id) ON DELETE CASCADE');
  26.         $this->addSql('ALTER TABLE voucher_store_campaign ADD CONSTRAINT FK_378F187BF639F774 FOREIGN KEY (campaign_id) REFERENCES campaign (id) ON DELETE CASCADE');
  27.         $this->addSql('ALTER TABLE voucher_import ADD voucher_store_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:guid)\'');
  28.         $this->addSql('ALTER TABLE voucher_import ADD CONSTRAINT FK_5CEA68E02E35F098 FOREIGN KEY (voucher_store_id) REFERENCES voucher_store (id)');
  29.         $this->addSql('CREATE INDEX IDX_5CEA68E02E35F098 ON voucher_import (voucher_store_id)');
  30. //        $this->addSql('ALTER TABLE voucher_redeem ADD CONSTRAINT FK_B68FB83140C6F396 FOREIGN KEY (to_order_id) REFERENCES orders (id)');
  31.     }
  32.     public function down(Schema $schema) : void
  33.     {
  34.         // this down() migration is auto-generated, please modify it to your needs
  35.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  36.         $this->addSql('ALTER TABLE voucher_import DROP FOREIGN KEY FK_5CEA68E02E35F098');
  37.         $this->addSql('ALTER TABLE voucher_purchase DROP FOREIGN KEY FK_FFB089B22E35F098');
  38.         $this->addSql('ALTER TABLE voucher_store_campaign DROP FOREIGN KEY FK_378F187B2E35F098');
  39.         $this->addSql('DROP TABLE voucher_purchase');
  40.         $this->addSql('DROP TABLE voucher_store');
  41.         $this->addSql('DROP TABLE voucher_store_campaign');
  42.         $this->addSql('DROP INDEX IDX_5CEA68E02E35F098 ON voucher_import');
  43.         $this->addSql('ALTER TABLE voucher_import DROP voucher_store_id');
  44. //        $this->addSql('ALTER TABLE voucher_redeem DROP FOREIGN KEY FK_B68FB83140C6F396');
  45.     }
  46. }