<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220922155643 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add Related Editors column';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE relatedEditors (editor_id INT NOT NULL, related_editor_id INT NOT NULL, INDEX IDX_AA34C2D16995AC4C (editor_id), INDEX IDX_AA34C2D1C154F057 (related_editor_id), PRIMARY KEY(editor_id, related_editor_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE relatedEditors ADD CONSTRAINT FK_AA34C2D16995AC4C FOREIGN KEY (editor_id) REFERENCES editor (id)');
$this->addSql('ALTER TABLE relatedEditors ADD CONSTRAINT FK_AA34C2D1C154F057 FOREIGN KEY (related_editor_id) REFERENCES editor (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE relatedEditors DROP FOREIGN KEY FK_AA34C2D16995AC4C');
$this->addSql('ALTER TABLE relatedEditors DROP FOREIGN KEY FK_AA34C2D1C154F057');
$this->addSql('DROP TABLE relatedEditors');
}
}