migrations/Version20230628132925.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * This file is part of Symfony Keen Template Project.
  5.  * (c) 2021 One AM SRL
  6.  */
  7. namespace App\Migrations;
  8. use Doctrine\DBAL\Schema\Schema;
  9. use Doctrine\Migrations\AbstractMigration;
  10. /**
  11.  * Auto-generated Migration: Please modify to your needs!
  12.  */
  13. final class Version20230628132925 extends AbstractMigration
  14. {
  15.     public function getDescription(): string
  16.     {
  17.         return '';
  18.     }
  19.     public function up(Schema $schema): void
  20.     {
  21.         // this up() migration is auto-generated, please modify it to your needs
  22.         $this->addSql('CREATE TABLE article_category (article_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_53A4EDAA7294869C (article_id), INDEX IDX_53A4EDAA12469DE2 (category_id), PRIMARY KEY(article_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('CREATE TABLE footer_entry (id INT AUTO_INCREMENT NOT NULL, position VARCHAR(255) NOT NULL, call_to_action VARCHAR(255) NOT NULL, link VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  24.         $this->addSql('ALTER TABLE article_category ADD CONSTRAINT FK_53A4EDAA7294869C FOREIGN KEY (article_id) REFERENCES article (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE article_category ADD CONSTRAINT FK_53A4EDAA12469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE');
  26.         $this->addSql('INSERT INTO article_category (article_id, category_id) SELECT id, category_id FROM article');
  27.         $this->addSql('ALTER TABLE article DROP FOREIGN KEY FK_23A0E6612469DE2');
  28.         $this->addSql('DROP INDEX IDX_23A0E6612469DE2 ON article');
  29.         $this->addSql('ALTER TABLE article DROP category_id');
  30.         $this->addSql('ALTER TABLE page ADD parent_id INT DEFAULT NULL');
  31.         $this->addSql('ALTER TABLE page ADD CONSTRAINT FK_140AB620727ACA70 FOREIGN KEY (parent_id) REFERENCES page (id)');
  32.         $this->addSql('CREATE INDEX IDX_140AB620727ACA70 ON page (parent_id)');
  33.         $this->addSql('ALTER TABLE talk_about_us ADD position INT NOT NULL');
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         // this down() migration is auto-generated, please modify it to your needs
  38.         $this->addSql('DROP TABLE article_category');
  39.         $this->addSql('DROP TABLE footer_entry');
  40.         $this->addSql('ALTER TABLE article ADD category_id INT NOT NULL');
  41.         $this->addSql('ALTER TABLE article ADD CONSTRAINT FK_23A0E6612469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
  42.         $this->addSql('CREATE INDEX IDX_23A0E6612469DE2 ON article (category_id)');
  43.         $this->addSql('ALTER TABLE page DROP FOREIGN KEY FK_140AB620727ACA70');
  44.         $this->addSql('DROP INDEX IDX_140AB620727ACA70 ON page');
  45.         $this->addSql('ALTER TABLE page DROP parent_id');
  46.         $this->addSql('ALTER TABLE talk_about_us DROP position');
  47.     }
  48. }