migrations/Version20200327171835.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 Version20200327171835 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('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE workflow_action (id INT AUTO_INCREMENT NOT NULL, workflow_id INT DEFAULT NULL, entity_type ENUM(\'customer\', \'lead\', \'event\', \'project\', \'feed\', \'issue\') NOT NULL COMMENT \'(DC2Type:WorkflowEntityType)\', action_type ENUM(\'create\', \'update\') NOT NULL COMMENT \'(DC2Type:WorkflowActionType)\', INDEX IDX_66C936512C7C2CBA (workflow_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE workflow_action_item (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, field_key VARCHAR(255) NOT NULL, field_type VARCHAR(255) NOT NULL, value LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', value_type ENUM(\'standard\', \'formula\') NOT NULL COMMENT \'(DC2Type:WorkflowValueType)\', INDEX IDX_3FD475ED9D32F035 (action_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE workflow_condition (id INT AUTO_INCREMENT NOT NULL, workflow_id INT DEFAULT NULL, field_key VARCHAR(255) NOT NULL, field_type VARCHAR(255) NOT NULL, operator ENUM(\'equals\', \'not_equals\', \'in\', \'contains\', \'greater\', \'less\', \'before\', \'after\') NOT NULL COMMENT \'(DC2Type:WorkflowOperatorType)\', value LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', value_type ENUM(\'standard\', \'formula\') NOT NULL COMMENT \'(DC2Type:WorkflowValueType)\', INDEX IDX_407F12C62C7C2CBA (workflow_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE workflow (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, entity_type ENUM(\'customer\', \'lead\', \'event\', \'project\', \'feed\', \'issue\') NOT NULL COMMENT \'(DC2Type:WorkflowEntityType)\', trigger_type ENUM(\'created\', \'created_or_updated\', \'created_or_updated_to_match\') NOT NULL COMMENT \'(DC2Type:WorkflowTriggerType)\', condition_logic ENUM(\'and\', \'or\') NOT NULL COMMENT \'(DC2Type:WorkflowConditionLogicType)\', enabled TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, INDEX IDX_65C59816A76ED395 (user_id), INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  23.         $this->addSql('ALTER TABLE workflow_action ADD CONSTRAINT FK_66C936512C7C2CBA FOREIGN KEY (workflow_id) REFERENCES workflow (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE workflow_action_item ADD CONSTRAINT FK_3FD475ED9D32F035 FOREIGN KEY (action_id) REFERENCES workflow_action (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE workflow_condition ADD CONSTRAINT FK_407F12C62C7C2CBA FOREIGN KEY (workflow_id) REFERENCES workflow (id) ON DELETE CASCADE');
  26.         $this->addSql('ALTER TABLE workflow ADD CONSTRAINT FK_65C59816A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
  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('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  32.         $this->addSql('ALTER TABLE workflow_action_item DROP FOREIGN KEY FK_3FD475ED9D32F035');
  33.         $this->addSql('ALTER TABLE workflow_action DROP FOREIGN KEY FK_66C936512C7C2CBA');
  34.         $this->addSql('ALTER TABLE workflow_condition DROP FOREIGN KEY FK_407F12C62C7C2CBA');
  35.         $this->addSql('DROP TABLE workflow_action');
  36.         $this->addSql('DROP TABLE workflow_action_item');
  37.         $this->addSql('DROP TABLE workflow_condition');
  38.         $this->addSql('DROP TABLE workflow');
  39.     }
  40. }