<?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 Version20250412175630 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_related (post_id INT NOT NULL, related_post_id INT NOT NULL, INDEX IDX_5DBFC7A34B89032C (post_id), INDEX IDX_5DBFC7A37490C989 (related_post_id), PRIMARY KEY(post_id, related_post_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE post_related ADD CONSTRAINT FK_5DBFC7A34B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
$this->addSql('ALTER TABLE post_related ADD CONSTRAINT FK_5DBFC7A37490C989 FOREIGN KEY (related_post_id) REFERENCES post (id)');
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8D4B89032C');
$this->addSql('DROP INDEX IDX_5A8A6C8D4B89032C ON post');
$this->addSql('ALTER TABLE post DROP post_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE post_related DROP FOREIGN KEY FK_5DBFC7A34B89032C');
$this->addSql('ALTER TABLE post_related DROP FOREIGN KEY FK_5DBFC7A37490C989');
$this->addSql('DROP TABLE post_related');
$this->addSql('ALTER TABLE post ADD post_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8D4B89032C FOREIGN KEY (post_id) REFERENCES post (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('CREATE INDEX IDX_5A8A6C8D4B89032C ON post (post_id)');
}
}