<?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 Version20220106055416 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('DROP INDEX news_translation_idx ON news_translations');
$this->addSql('ALTER TABLE news_translations ADD object_id INT DEFAULT NULL, DROP object_class, DROP foreign_key');
$this->addSql('ALTER TABLE news_translations ADD CONSTRAINT FK_20FDB330232D562B FOREIGN KEY (object_id) REFERENCES news (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_20FDB330232D562B ON news_translations (object_id)');
$this->addSql('CREATE INDEX news_translation_idx ON news_translations (locale, object_id, field)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE news_translations DROP FOREIGN KEY FK_20FDB330232D562B');
$this->addSql('DROP INDEX IDX_20FDB330232D562B ON news_translations');
$this->addSql('DROP INDEX news_translation_idx ON news_translations');
$this->addSql('ALTER TABLE news_translations ADD object_class VARCHAR(191) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ADD foreign_key VARCHAR(64) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, DROP object_id');
$this->addSql('CREATE INDEX news_translation_idx ON news_translations (locale, object_class, field, foreign_key)');
}
}