<?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 Version20251209094514 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 products_upsells DROP FOREIGN KEY FK_207C29C1E6992E');
$this->addSql('ALTER TABLE products_upsells DROP FOREIGN KEY FK_207C294584665A');
$this->addSql('ALTER TABLE products_upsells ADD id INT AUTO_INCREMENT NOT NULL, ADD position INT DEFAULT 0 NOT NULL, CHANGE product_id product_id INT DEFAULT NULL, CHANGE upsell_id upsell_id INT DEFAULT NULL, DROP PRIMARY KEY, ADD PRIMARY KEY (id)');
$this->addSql('ALTER TABLE products_upsells ADD CONSTRAINT FK_207C29C1E6992E FOREIGN KEY (upsell_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE products_upsells ADD CONSTRAINT FK_207C294584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE products_upsells MODIFY id INT NOT NULL');
$this->addSql('ALTER TABLE products_upsells DROP FOREIGN KEY FK_207C294584665A');
$this->addSql('ALTER TABLE products_upsells DROP FOREIGN KEY FK_207C29C1E6992E');
$this->addSql('ALTER TABLE products_upsells DROP PRIMARY KEY');
$this->addSql('ALTER TABLE products_upsells DROP id, DROP position, CHANGE product_id product_id INT NOT NULL, CHANGE upsell_id upsell_id INT NOT NULL');
$this->addSql('ALTER TABLE products_upsells ADD CONSTRAINT FK_207C294584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE products_upsells ADD CONSTRAINT FK_207C29C1E6992E FOREIGN KEY (upsell_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE products_upsells ADD PRIMARY KEY (product_id, upsell_id)');
}
}