migrations/Version20181017220738.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 Version20181017220738 extends AbstractMigration
  10. {
  11.     public function up(Schema $schema): void
  12.     {
  13.         // this up() migration is auto-generated, please modify it to your needs
  14.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  15.         $this->addSql('
  16.             CREATE TABLE customer_interview_note_join_customer_tag (
  17.                 interview_note_id INT NOT NULL,
  18.                 tag_id INT NOT NULL,
  19.                 INDEX IDX_8AE56057E8EC15C6 (interview_note_id),
  20.                 INDEX IDX_8AE56057BAD26311 (tag_id),
  21.                 PRIMARY KEY(interview_note_id, tag_id)
  22.             ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
  23.         ');
  24.         $this->addSql('
  25.             CREATE TABLE customer_tag (
  26.                 id INT AUTO_INCREMENT NOT NULL,
  27.                 name VARCHAR(255) NOT NULL,
  28.                 color VARCHAR(6) DEFAULT NULL,
  29.                 INDEX idx_name (name),
  30.                 PRIMARY KEY(id)
  31.             ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
  32.         ');
  33.         $this->addSql('
  34.             INSERT INTO customer_tag (id, name, color)
  35.             VALUES
  36.                 (1, \'Update\', \'b71c1c\'),
  37.                 (2, \'Question\', \'FBC02D\'),
  38.                 (3, \'Concern\', \'880E4F\'),
  39.                 (4, \'Complaint\', \'4A148C\'),
  40.                 (5, \'Levy\', \'FF6F00\'),
  41.                 (6, \'Return\', \'BF360C\'),
  42.                 (7, \'Book\', \'263238\'),
  43.                 (8, \'Payroll\', \'004D40\'),
  44.                 (9, \'Payment\', \'1B5E20\')
  45.         ');
  46.         $this->addSql('ALTER TABLE customer_interview_note_join_customer_tag ADD CONSTRAINT FK_8AE56057E8EC15C6 FOREIGN KEY (interview_note_id) REFERENCES customer_interview_note (id) ON DELETE CASCADE');
  47.         $this->addSql('ALTER TABLE customer_interview_note_join_customer_tag ADD CONSTRAINT FK_8AE56057BAD26311 FOREIGN KEY (tag_id) REFERENCES customer_tag (id) ON DELETE CASCADE');
  48.     }
  49.     public function down(Schema $schema): void
  50.     {
  51.         // this down() migration is auto-generated, please modify it to your needs
  52.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  53.         $this->addSql('ALTER TABLE customer_interview_note_join_customer_tag DROP FOREIGN KEY FK_8AE56057BAD26311');
  54.         $this->addSql('DROP TABLE customer_interview_note_join_customer_tag');
  55.         $this->addSql('DROP TABLE customer_tag');
  56.     }
  57. }