<?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 Version20240211101142 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('DROP INDEX unique_product_imghash ON products__images');
$this->addSql('ALTER TABLE products__images ADD created_at DATETIME DEFAULT NULL, CHANGE hash src VARCHAR(255) NOT NULL');
$this->addSql('UPDATE products__images SET created_at = NOW()');
$this->addSql('ALTER TABLE products__images CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_C211A3B46044248D4584665A ON products__images (src, product_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_C211A3B46044248D4584665A ON products__images');
$this->addSql('ALTER TABLE products__images DROP created_at, CHANGE src hash VARCHAR(255) NOT NULL');
$this->addSql('CREATE UNIQUE INDEX unique_product_imghash ON products__images (hash, product_id)');
}
}