migrations/Version20220922155643.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. final class Version20220922155643 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add Related Editors column';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $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');
  15.         $this->addSql('ALTER TABLE relatedEditors ADD CONSTRAINT FK_AA34C2D16995AC4C FOREIGN KEY (editor_id) REFERENCES editor (id)');
  16.         $this->addSql('ALTER TABLE relatedEditors ADD CONSTRAINT FK_AA34C2D1C154F057 FOREIGN KEY (related_editor_id) REFERENCES editor (id)');
  17.     }
  18.     public function down(Schema $schema): void
  19.     {
  20.         $this->addSql('ALTER TABLE relatedEditors DROP FOREIGN KEY FK_AA34C2D16995AC4C');
  21.         $this->addSql('ALTER TABLE relatedEditors DROP FOREIGN KEY FK_AA34C2D1C154F057');
  22.         $this->addSql('DROP TABLE relatedEditors');
  23.     }
  24. }