<?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 Version20200225222156 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_redeem (id INT AUTO_INCREMENT NOT NULL, voucher_id INT NOT NULL, amount NUMERIC(10, 2) DEFAULT NULL, INDEX IDX_B68FB83128AA1B6F (voucher_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE voucher_redeem ADD CONSTRAINT FK_B68FB83128AA1B6F FOREIGN KEY (voucher_id) REFERENCES voucher (id)');
$this->addSql('ALTER TABLE campaign ADD dedicated TINYINT(1) NOT NULL, ADD number_of_redeems INT DEFAULT NULL, ADD number_of_redeems_per_customer INT DEFAULT NULL');
$this->addSql('ALTER TABLE voucher ADD customer_id INT DEFAULT NULL, ADD split_count INT NOT NULL');
$this->addSql('ALTER TABLE voucher ADD CONSTRAINT FK_1392A5D89395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
$this->addSql('CREATE INDEX IDX_1392A5D89395C3F3 ON voucher (customer_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('DROP TABLE voucher_redeem');
$this->addSql('ALTER TABLE campaign DROP dedicated, DROP number_of_redeems, DROP number_of_redeems_per_customer');
$this->addSql('ALTER TABLE voucher DROP FOREIGN KEY FK_1392A5D89395C3F3');
$this->addSql('DROP INDEX IDX_1392A5D89395C3F3 ON voucher');
$this->addSql('ALTER TABLE voucher DROP customer_id, DROP split_count');
}
}