migrations/Version20221227102114.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 Version20221227102114 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_comment (id INT AUTO_INCREMENT NOT NULL, author_id INT DEFAULT NULL, post_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, comment LONGTEXT NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_5C47A2A9F675F31B (author_id), INDEX IDX_5C47A2A94B89032C (post_id), INDEX IDX_5C47A2A9727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE wiki_comment ADD CONSTRAINT FK_5C47A2A9F675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
  20.         $this->addSql('ALTER TABLE wiki_comment ADD CONSTRAINT FK_5C47A2A94B89032C FOREIGN KEY (post_id) REFERENCES wiki_post (id)');
  21.         $this->addSql('ALTER TABLE wiki_comment ADD CONSTRAINT FK_5C47A2A9727ACA70 FOREIGN KEY (parent_id) REFERENCES wiki_comment (id)');
  22.         $this->addSql('ALTER TABLE wiki_post ADD comment_count INT DEFAULT 0 NOT NULL');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->addSql('ALTER TABLE wiki_comment DROP FOREIGN KEY FK_5C47A2A9F675F31B');
  28.         $this->addSql('ALTER TABLE wiki_comment DROP FOREIGN KEY FK_5C47A2A94B89032C');
  29.         $this->addSql('ALTER TABLE wiki_comment DROP FOREIGN KEY FK_5C47A2A9727ACA70');
  30.         $this->addSql('DROP TABLE wiki_comment');
  31.         $this->addSql('ALTER TABLE wiki_post DROP comment_count');
  32.     }
  33. }