migrations/Version20220531152806.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 Version20220531152806 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 post_comment (id INT AUTO_INCREMENT NOT NULL, post_id INT NOT NULL, profile_id INT NOT NULL, parent_id INT DEFAULT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME DEFAULT NULL, INDEX IDX_A99CE55F4B89032C (post_id), INDEX IDX_A99CE55FCCFA12B8 (profile_id), INDEX IDX_A99CE55F727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE post_media (id INT AUTO_INCREMENT NOT NULL, post_id INT DEFAULT NULL, media_type VARCHAR(255) DEFAULT NULL, media_file VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, INDEX IDX_FD372DE34B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE post_comment ADD CONSTRAINT FK_A99CE55F4B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
  21.         $this->addSql('ALTER TABLE post_comment ADD CONSTRAINT FK_A99CE55FCCFA12B8 FOREIGN KEY (profile_id) REFERENCES user_profile (id)');
  22.         $this->addSql('ALTER TABLE post_comment ADD CONSTRAINT FK_A99CE55F727ACA70 FOREIGN KEY (parent_id) REFERENCES post_comment (id)');
  23.         $this->addSql('ALTER TABLE post_media ADD CONSTRAINT FK_FD372DE34B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
  24.         $this->addSql('ALTER TABLE post ADD section_id INT DEFAULT NULL, ADD profile_id INT DEFAULT NULL, ADD description LONGTEXT DEFAULT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME DEFAULT NULL');
  25.         $this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8DD823E37A FOREIGN KEY (section_id) REFERENCES `section` (id)');
  26.         $this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8DCCFA12B8 FOREIGN KEY (profile_id) REFERENCES user_profile (id)');
  27.         $this->addSql('CREATE INDEX IDX_5A8A6C8DD823E37A ON post (section_id)');
  28.         $this->addSql('CREATE INDEX IDX_5A8A6C8DCCFA12B8 ON post (profile_id)');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('ALTER TABLE post_comment DROP FOREIGN KEY FK_A99CE55F727ACA70');
  34.         $this->addSql('DROP TABLE post_comment');
  35.         $this->addSql('DROP TABLE post_media');
  36.         $this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8DD823E37A');
  37.         $this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8DCCFA12B8');
  38.         $this->addSql('DROP INDEX IDX_5A8A6C8DD823E37A ON post');
  39.         $this->addSql('DROP INDEX IDX_5A8A6C8DCCFA12B8 ON post');
  40.         $this->addSql('ALTER TABLE post DROP section_id, DROP profile_id, DROP description, DROP created_at, DROP updated_at');
  41.     }
  42. }