<?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 Version20260622084240 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 channel_company_contacts DROP FOREIGN KEY FK_126D19A5E7A1254A');
$this->addSql('DROP INDEX IDX_126D19A5E7A1254A ON channel_company_contacts');
$this->addSql('ALTER TABLE channel_company_contacts CHANGE contact_id channel_contact_id VARCHAR(36) NOT NULL');
$this->addSql('
UPDATE channel_company_contacts ccc
INNER JOIN channel_company cc ON cc.id = ccc.company_id
INNER JOIN channel_contacts chc
ON chc.contact_id = ccc.channel_contact_id
AND chc.channel_id = cc.channel_id
SET ccc.channel_contact_id = chc.id
');
$this->addSql('ALTER TABLE channel_company_contacts ADD CONSTRAINT FK_126D19A5516875DC FOREIGN KEY (channel_contact_id) REFERENCES channel_contacts (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_126D19A5516875DC ON channel_company_contacts (channel_contact_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE channel_company_contacts DROP FOREIGN KEY FK_126D19A5516875DC');
$this->addSql('DROP INDEX IDX_126D19A5516875DC ON channel_company_contacts');
$this->addSql('ALTER TABLE channel_company_contacts CHANGE channel_contact_id contact_id VARCHAR(36) NOT NULL');
$this->addSql('ALTER TABLE channel_company_contacts ADD CONSTRAINT FK_126D19A5E7A1254A FOREIGN KEY (contact_id) REFERENCES contacts (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_126D19A5E7A1254A ON channel_company_contacts (contact_id)');
}
}