<?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 Version20231023161523 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('ALTER TABLE product_translation ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL');
$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)');
$this->addSql('ALTER TABLE product_translation MODIFY created_at DATETIME NOT NULL, MODIFY updated_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE category_translation ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL');
$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)');
$this->addSql('ALTER TABLE category_translation MODIFY created_at DATETIME NOT NULL, MODIFY updated_at DATETIME NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE product_translation DROP created_at, DROP updated_at');
$this->addSql('ALTER TABLE category_translation DROP created_at, DROP updated_at');
}
}