migrations/Version20200225222156.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 Version20200225222156 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_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');
  20.         $this->addSql('ALTER TABLE voucher_redeem ADD CONSTRAINT FK_B68FB83128AA1B6F FOREIGN KEY (voucher_id) REFERENCES voucher (id)');
  21.         $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');
  22.         $this->addSql('ALTER TABLE voucher ADD customer_id INT DEFAULT NULL, ADD split_count INT NOT NULL');
  23.         $this->addSql('ALTER TABLE voucher ADD CONSTRAINT FK_1392A5D89395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
  24.         $this->addSql('CREATE INDEX IDX_1392A5D89395C3F3 ON voucher (customer_id)');
  25.     }
  26.     public function down(Schema $schema) : void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  30.         $this->addSql('DROP TABLE voucher_redeem');
  31.         $this->addSql('ALTER TABLE campaign DROP dedicated, DROP number_of_redeems, DROP number_of_redeems_per_customer');
  32.         $this->addSql('ALTER TABLE voucher DROP FOREIGN KEY FK_1392A5D89395C3F3');
  33.         $this->addSql('DROP INDEX IDX_1392A5D89395C3F3 ON voucher');
  34.         $this->addSql('ALTER TABLE voucher DROP customer_id, DROP split_count');
  35.     }
  36. }