migrations/Version20220106055416.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 Version20220106055416 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('DROP INDEX news_translation_idx ON news_translations');
  19.         $this->addSql('ALTER TABLE news_translations ADD object_id INT DEFAULT NULL, DROP object_class, DROP foreign_key');
  20.         $this->addSql('ALTER TABLE news_translations ADD CONSTRAINT FK_20FDB330232D562B FOREIGN KEY (object_id) REFERENCES news (id) ON DELETE CASCADE');
  21.         $this->addSql('CREATE INDEX IDX_20FDB330232D562B ON news_translations (object_id)');
  22.         $this->addSql('CREATE INDEX news_translation_idx ON news_translations (locale, object_id, field)');
  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 news_translations DROP FOREIGN KEY FK_20FDB330232D562B');
  28.         $this->addSql('DROP INDEX IDX_20FDB330232D562B ON news_translations');
  29.         $this->addSql('DROP INDEX news_translation_idx ON news_translations');
  30.         $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');
  31.         $this->addSql('CREATE INDEX news_translation_idx ON news_translations (locale, object_class, field, foreign_key)');
  32.     }
  33. }