<?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 Version20200309133611 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$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');
$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');
$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');
$this->addSql('ALTER TABLE voucher_purchase ADD CONSTRAINT FK_FFB089B22E35F098 FOREIGN KEY (voucher_store_id) REFERENCES voucher_store (id)');
$this->addSql('ALTER TABLE voucher_purchase ADD CONSTRAINT FK_FFB089B228AA1B6F FOREIGN KEY (voucher_id) REFERENCES voucher (id)');
$this->addSql('ALTER TABLE voucher_purchase ADD CONSTRAINT FK_FFB089B240C6F396 FOREIGN KEY (to_order_id) REFERENCES orders (id)');
$this->addSql('ALTER TABLE voucher_store_campaign ADD CONSTRAINT FK_378F187B2E35F098 FOREIGN KEY (voucher_store_id) REFERENCES voucher_store (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE voucher_store_campaign ADD CONSTRAINT FK_378F187BF639F774 FOREIGN KEY (campaign_id) REFERENCES campaign (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE voucher_import ADD voucher_store_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:guid)\'');
$this->addSql('ALTER TABLE voucher_import ADD CONSTRAINT FK_5CEA68E02E35F098 FOREIGN KEY (voucher_store_id) REFERENCES voucher_store (id)');
$this->addSql('CREATE INDEX IDX_5CEA68E02E35F098 ON voucher_import (voucher_store_id)');
// $this->addSql('ALTER TABLE voucher_redeem ADD CONSTRAINT FK_B68FB83140C6F396 FOREIGN KEY (to_order_id) REFERENCES orders (id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE voucher_import DROP FOREIGN KEY FK_5CEA68E02E35F098');
$this->addSql('ALTER TABLE voucher_purchase DROP FOREIGN KEY FK_FFB089B22E35F098');
$this->addSql('ALTER TABLE voucher_store_campaign DROP FOREIGN KEY FK_378F187B2E35F098');
$this->addSql('DROP TABLE voucher_purchase');
$this->addSql('DROP TABLE voucher_store');
$this->addSql('DROP TABLE voucher_store_campaign');
$this->addSql('DROP INDEX IDX_5CEA68E02E35F098 ON voucher_import');
$this->addSql('ALTER TABLE voucher_import DROP voucher_store_id');
// $this->addSql('ALTER TABLE voucher_redeem DROP FOREIGN KEY FK_B68FB83140C6F396');
}
}