<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220531152806 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$this->addSql('ALTER TABLE post_comment ADD CONSTRAINT FK_A99CE55F4B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
$this->addSql('ALTER TABLE post_comment ADD CONSTRAINT FK_A99CE55FCCFA12B8 FOREIGN KEY (profile_id) REFERENCES user_profile (id)');
$this->addSql('ALTER TABLE post_comment ADD CONSTRAINT FK_A99CE55F727ACA70 FOREIGN KEY (parent_id) REFERENCES post_comment (id)');
$this->addSql('ALTER TABLE post_media ADD CONSTRAINT FK_FD372DE34B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
$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');
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8DD823E37A FOREIGN KEY (section_id) REFERENCES `section` (id)');
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8DCCFA12B8 FOREIGN KEY (profile_id) REFERENCES user_profile (id)');
$this->addSql('CREATE INDEX IDX_5A8A6C8DD823E37A ON post (section_id)');
$this->addSql('CREATE INDEX IDX_5A8A6C8DCCFA12B8 ON post (profile_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE post_comment DROP FOREIGN KEY FK_A99CE55F727ACA70');
$this->addSql('DROP TABLE post_comment');
$this->addSql('DROP TABLE post_media');
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8DD823E37A');
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8DCCFA12B8');
$this->addSql('DROP INDEX IDX_5A8A6C8DD823E37A ON post');
$this->addSql('DROP INDEX IDX_5A8A6C8DCCFA12B8 ON post');
$this->addSql('ALTER TABLE post DROP section_id, DROP profile_id, DROP description, DROP created_at, DROP updated_at');
}
}