<?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 Version20201204113259 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 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');
$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');
$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');
$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');
$this->addSql('ALTER TABLE coupon_builder ADD CONSTRAINT FK_394FECDF131A730F FOREIGN KEY (email_template_id) REFERENCES email_template (id)');
$this->addSql('ALTER TABLE coupon_builder_attribute ADD CONSTRAINT FK_8B8D81DF5098FDC FOREIGN KEY (`couponBuilder_id`) REFERENCES coupon_builder (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE gift_rule_coupon_builder ADD CONSTRAINT FK_C36B243B181430FE FOREIGN KEY (gift_rule_id) REFERENCES gift_rule (id)');
$this->addSql('ALTER TABLE gift_rule_coupon_builder ADD CONSTRAINT FK_C36B243BCD6ACD0E FOREIGN KEY (`coupon_id`) REFERENCES coupon_builder (`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 coupon_builder_attribute DROP FOREIGN KEY FK_8B8D81DF5098FDC');
$this->addSql('ALTER TABLE gift_rule_coupon_builder DROP FOREIGN KEY FK_C36B243BCD6ACD0E');
$this->addSql('ALTER TABLE gift_rule_coupon_builder DROP FOREIGN KEY FK_C36B243B181430FE');
$this->addSql('DROP TABLE coupon_builder');
$this->addSql('DROP TABLE coupon_builder_attribute');
$this->addSql('DROP TABLE gift_rule');
$this->addSql('DROP TABLE gift_rule_coupon_builder');
}
}