<?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 Version20191010145620 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('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE project_item_join_project_tag (item_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_2BD61BA3126F525E (item_id), INDEX IDX_2BD61BA3BAD26311 (tag_id), PRIMARY KEY(item_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE project_item_join_project_tag ADD CONSTRAINT FK_2BD61BA3126F525E FOREIGN KEY (item_id) REFERENCES project_item (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE project_item_join_project_tag ADD CONSTRAINT FK_2BD61BA3BAD26311 FOREIGN KEY (tag_id) REFERENCES project_tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE project_item DROP FOREIGN KEY FK_268AED06BAD26311');
$this->addSql('DROP INDEX IDX_268AED06BAD26311 ON project_item');
$this->addSql('ALTER TABLE project_item DROP tag_id');
}
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('DROP TABLE project_item_join_project_tag');
$this->addSql('ALTER TABLE project_item ADD tag_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE project_item ADD CONSTRAINT FK_268AED06BAD26311 FOREIGN KEY (tag_id) REFERENCES project_tag (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_268AED06BAD26311 ON project_item (tag_id)');
}
}