<?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 Version20220711063734 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_video MODIFY id INT NOT NULL');
$this->addSql('ALTER TABLE product_video DROP FOREIGN KEY FK_DD9BA17029C1004E');
$this->addSql('ALTER TABLE product_video DROP PRIMARY KEY');
$this->addSql('ALTER TABLE product_video ADD product_id INT NOT NULL, DROP id, CHANGE video_id video_id INT NOT NULL');
$this->addSql('ALTER TABLE product_video ADD CONSTRAINT FK_DD9BA1704584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE product_video ADD CONSTRAINT FK_DD9BA17029C1004E FOREIGN KEY (video_id) REFERENCES video (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_DD9BA1704584665A ON product_video (product_id)');
$this->addSql('ALTER TABLE product_video ADD PRIMARY KEY (product_id, video_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE product_video DROP FOREIGN KEY FK_DD9BA1704584665A');
$this->addSql('ALTER TABLE product_video DROP FOREIGN KEY FK_DD9BA17029C1004E');
$this->addSql('DROP INDEX IDX_DD9BA1704584665A ON product_video');
$this->addSql('ALTER TABLE product_video ADD id INT AUTO_INCREMENT NOT NULL, DROP product_id, CHANGE video_id video_id INT DEFAULT NULL, DROP PRIMARY KEY, ADD PRIMARY KEY (id)');
$this->addSql('ALTER TABLE product_video ADD CONSTRAINT FK_DD9BA17029C1004E FOREIGN KEY (video_id) REFERENCES video (id)');
}
}