migrations/Version20201204113259.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 Version20201204113259 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 coupon_builder (email_template_id INT DEFAULT NULL, `id` INT AUTO_INCREMENT NOT NULL, `cod` VARCHAR(50) NOT NULL, `name` VARCHAR(200) NOT NULL, `description` VARCHAR(1000) DEFAULT NULL, `amount` INT NOT NULL, `expired_date` DATE DEFAULT NULL, `creation_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_394FECDF131A730F (email_template_id), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE coupon_builder_attribute (`id` INT AUTO_INCREMENT NOT NULL, `key` VARCHAR(255) NOT NULL, `value` VARCHAR(255) NOT NULL, `couponBuilder_id` INT NOT NULL, INDEX IDX_8B8D81DF5098FDC (`couponBuilder_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE gift_rule (`id` INT AUTO_INCREMENT NOT NULL, `name` VARCHAR(100) DEFAULT NULL, `gift_type` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:gift_type)\', `start_date` DATE NOT NULL, `end_date` DATE NOT NULL, `creation_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, type VARCHAR(3) NOT NULL, `product_category_id` INT DEFAULT NULL, `product_id` LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:simple_array)\', `variants_product_id` LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:simple_array)\', `status` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:membership_status)\', `born_date` TINYINT(1) DEFAULT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE gift_rule_coupon_builder (gift_rule_id INT DEFAULT NULL, `id` INT AUTO_INCREMENT NOT NULL, `coupon_id` INT NOT NULL, INDEX IDX_C36B243B181430FE (gift_rule_id), INDEX IDX_C36B243BCD6ACD0E (`coupon_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('ALTER TABLE coupon_builder ADD CONSTRAINT FK_394FECDF131A730F FOREIGN KEY (email_template_id) REFERENCES email_template (id)');
  24.         $this->addSql('ALTER TABLE coupon_builder_attribute ADD CONSTRAINT FK_8B8D81DF5098FDC FOREIGN KEY (`couponBuilder_id`) REFERENCES coupon_builder (`id`) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE gift_rule_coupon_builder ADD CONSTRAINT FK_C36B243B181430FE FOREIGN KEY (gift_rule_id) REFERENCES gift_rule (id)');
  26.         $this->addSql('ALTER TABLE gift_rule_coupon_builder ADD CONSTRAINT FK_C36B243BCD6ACD0E FOREIGN KEY (`coupon_id`) REFERENCES coupon_builder (`id`)');
  27.     }
  28.     public function down(Schema $schema) : void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  32.         $this->addSql('ALTER TABLE coupon_builder_attribute DROP FOREIGN KEY FK_8B8D81DF5098FDC');
  33.         $this->addSql('ALTER TABLE gift_rule_coupon_builder DROP FOREIGN KEY FK_C36B243BCD6ACD0E');
  34.         $this->addSql('ALTER TABLE gift_rule_coupon_builder DROP FOREIGN KEY FK_C36B243B181430FE');
  35.         $this->addSql('DROP TABLE coupon_builder');
  36.         $this->addSql('DROP TABLE coupon_builder_attribute');
  37.         $this->addSql('DROP TABLE gift_rule');
  38.         $this->addSql('DROP TABLE gift_rule_coupon_builder');
  39.     }
  40. }