migrations/Version20231023161523.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 Version20231023161523 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 product_translation ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL');
  19.         $this->addSql('UPDATE product_translation pt SET created_at = (SELECT created_at FROM product p WHERE pt.product_id = p.id), updated_at = (SELECT updated_at FROM product p WHERE pt.product_id = p.id)');
  20.         $this->addSql('ALTER TABLE product_translation MODIFY created_at DATETIME NOT NULL, MODIFY updated_at DATETIME NOT NULL');
  21.         $this->addSql('ALTER TABLE category_translation ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL');
  22.         $this->addSql('UPDATE category_translation ct SET created_at = (SELECT created_at FROM category c WHERE ct.category_id = c.id), updated_at = (SELECT updated_at FROM category c WHERE ct.category_id = c.id)');
  23.         $this->addSql('ALTER TABLE category_translation MODIFY created_at DATETIME NOT NULL, MODIFY updated_at DATETIME NOT NULL');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->addSql('ALTER TABLE product_translation DROP created_at, DROP updated_at');
  29.         $this->addSql('ALTER TABLE category_translation DROP created_at, DROP updated_at');
  30.     }
  31. }