<?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 Version20181017220738 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('
CREATE TABLE customer_interview_note_join_customer_tag (
interview_note_id INT NOT NULL,
tag_id INT NOT NULL,
INDEX IDX_8AE56057E8EC15C6 (interview_note_id),
INDEX IDX_8AE56057BAD26311 (tag_id),
PRIMARY KEY(interview_note_id, tag_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
');
$this->addSql('
CREATE TABLE customer_tag (
id INT AUTO_INCREMENT NOT NULL,
name VARCHAR(255) NOT NULL,
color VARCHAR(6) DEFAULT NULL,
INDEX idx_name (name),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
');
$this->addSql('
INSERT INTO customer_tag (id, name, color)
VALUES
(1, \'Update\', \'b71c1c\'),
(2, \'Question\', \'FBC02D\'),
(3, \'Concern\', \'880E4F\'),
(4, \'Complaint\', \'4A148C\'),
(5, \'Levy\', \'FF6F00\'),
(6, \'Return\', \'BF360C\'),
(7, \'Book\', \'263238\'),
(8, \'Payroll\', \'004D40\'),
(9, \'Payment\', \'1B5E20\')
');
$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');
$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');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE customer_interview_note_join_customer_tag DROP FOREIGN KEY FK_8AE56057BAD26311');
$this->addSql('DROP TABLE customer_interview_note_join_customer_tag');
$this->addSql('DROP TABLE customer_tag');
}
}