migrations/Version20221111131501.php line 1

  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 Version20221111131501 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 wiki_post (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, status VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE wiki_post_category (category_id INT NOT NULL, post_id INT NOT NULL, INDEX IDX_CD92DF8D12469DE2 (category_id), INDEX IDX_CD92DF8D4B89032C (post_id), PRIMARY KEY(category_id, post_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE wiki_post_tag (tag_id INT NOT NULL, post_id INT NOT NULL, INDEX IDX_B1083F3FBAD26311 (tag_id), INDEX IDX_B1083F3F4B89032C (post_id), PRIMARY KEY(tag_id, post_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE wiki_tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('ALTER TABLE wiki_post_category ADD CONSTRAINT FK_CD92DF8D12469DE2 FOREIGN KEY (category_id) REFERENCES wiki_post (id)');
  23.         $this->addSql('ALTER TABLE wiki_post_category ADD CONSTRAINT FK_CD92DF8D4B89032C FOREIGN KEY (post_id) REFERENCES wiki_category (id)');
  24.         $this->addSql('ALTER TABLE wiki_post_tag ADD CONSTRAINT FK_B1083F3FBAD26311 FOREIGN KEY (tag_id) REFERENCES wiki_post (id)');
  25.         $this->addSql('ALTER TABLE wiki_post_tag ADD CONSTRAINT FK_B1083F3F4B89032C FOREIGN KEY (post_id) REFERENCES wiki_tag (id)');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE wiki_post_category DROP FOREIGN KEY FK_CD92DF8D12469DE2');
  31.         $this->addSql('ALTER TABLE wiki_post_tag DROP FOREIGN KEY FK_B1083F3FBAD26311');
  32.         $this->addSql('ALTER TABLE wiki_post_tag DROP FOREIGN KEY FK_B1083F3F4B89032C');
  33.         $this->addSql('DROP TABLE wiki_post');
  34.         $this->addSql('DROP TABLE wiki_post_category');
  35.         $this->addSql('DROP TABLE wiki_post_tag');
  36.         $this->addSql('DROP TABLE wiki_tag');
  37.     }
  38. }