migrations/Version20210826102149.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 Version20210826102149 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE topic_section (`id` INT AUTO_INCREMENT NOT NULL, `category` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:topic_section_category_type)\', `name` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:topic_section_type)\', `visibility` LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:simple_array)\', `create_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE topic_section_blog (topic_section_id INT NOT NULL, blog_page_id INT NOT NULL, INDEX IDX_1BAE3ADC1D704D50 (topic_section_id), INDEX IDX_1BAE3ADCE0B0DE67 (blog_page_id), PRIMARY KEY(topic_section_id, blog_page_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE topic_section_media_category (topic_section_id INT NOT NULL, media_category_id INT NOT NULL, INDEX IDX_C5E366201D704D50 (topic_section_id), INDEX IDX_C5E36620E52EEF71 (media_category_id), PRIMARY KEY(topic_section_id, media_category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE topic_section_media (topic_section_id INT NOT NULL, media_id INT NOT NULL, INDEX IDX_A4794B21D704D50 (topic_section_id), INDEX IDX_A4794B2EA9FDD75 (media_id), PRIMARY KEY(topic_section_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('ALTER TABLE topic_section_blog ADD CONSTRAINT FK_1BAE3ADC1D704D50 FOREIGN KEY (topic_section_id) REFERENCES topic_section (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE topic_section_blog ADD CONSTRAINT FK_1BAE3ADCE0B0DE67 FOREIGN KEY (blog_page_id) REFERENCES blog_page (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE topic_section_media_category ADD CONSTRAINT FK_C5E366201D704D50 FOREIGN KEY (topic_section_id) REFERENCES topic_section (id) ON DELETE CASCADE');
  26.         $this->addSql('ALTER TABLE topic_section_media_category ADD CONSTRAINT FK_C5E36620E52EEF71 FOREIGN KEY (media_category_id) REFERENCES media_category (id) ON DELETE CASCADE');
  27.         $this->addSql('ALTER TABLE topic_section_media ADD CONSTRAINT FK_A4794B21D704D50 FOREIGN KEY (topic_section_id) REFERENCES topic_section (id) ON DELETE CASCADE');
  28.         $this->addSql('ALTER TABLE topic_section_media ADD CONSTRAINT FK_A4794B2EA9FDD75 FOREIGN KEY (media_id) REFERENCES media (id) ON DELETE CASCADE');
  29.     }
  30.     public function down(Schema $schema) : void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  34.         
  35.         $this->addSql('DROP TABLE topic_section');
  36.         $this->addSql('DROP TABLE topic_section_blog');
  37.         $this->addSql('DROP TABLE topic_section_media_category');
  38.         $this->addSql('DROP TABLE topic_section_media');
  39.     }
  40. }