migrations/Version20220228202936.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 Version20220228202936 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE publications_authors (publication_id INT NOT NULL, author_id INT NOT NULL, INDEX IDX_B1E64FCA38B217A7 (publication_id), INDEX IDX_B1E64FCAF675F31B (author_id), PRIMARY KEY(publication_id, author_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE publications_keywords (publication_id INT NOT NULL, keyword_id INT NOT NULL, INDEX IDX_CDBD15F738B217A7 (publication_id), INDEX IDX_CDBD15F7115D4552 (keyword_id), PRIMARY KEY(publication_id, keyword_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE publications_authors ADD CONSTRAINT FK_B1E64FCA38B217A7 FOREIGN KEY (publication_id) REFERENCES publication (id) ON DELETE CASCADE');
  21.         $this->addSql('ALTER TABLE publications_authors ADD CONSTRAINT FK_B1E64FCAF675F31B FOREIGN KEY (author_id) REFERENCES author (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE publications_keywords ADD CONSTRAINT FK_CDBD15F738B217A7 FOREIGN KEY (publication_id) REFERENCES publication (id) ON DELETE CASCADE');
  23.         $this->addSql('ALTER TABLE publications_keywords ADD CONSTRAINT FK_CDBD15F7115D4552 FOREIGN KEY (keyword_id) REFERENCES keyword (id) ON DELETE CASCADE');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->addSql('DROP TABLE publications_authors');
  29.         $this->addSql('DROP TABLE publications_keywords');
  30.     }
  31. }