migrations/Version20231124154855.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 Version20231124154855 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('ALTER TABLE category ADD disabled_at DATETIME DEFAULT NULL');
  19.         $this->addSql('ALTER TABLE product ADD disabled_at DATETIME DEFAULT NULL');
  20.         $this->addSql('DELETE pc FROM product_category pc
  21.                    JOIN product p ON pc.product_id = p.id
  22.                    JOIN category c ON pc.category_id = c.id
  23.                    WHERE c.status = 0 OR p.status = 0
  24.                    OR c.deleted_at IS NOT NULL OR p.deleted_at IS NOT NULL
  25.                    OR pc.deleted_at IS NOT NULL');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE category DROP disabled_at');
  31.         $this->addSql('ALTER TABLE product DROP disabled_at');
  32.     }
  33. }