migrations/Version20260622084240.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20260622084240 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('ALTER TABLE channel_company_contacts DROP FOREIGN KEY FK_126D19A5E7A1254A');
  19.         $this->addSql('DROP INDEX IDX_126D19A5E7A1254A ON channel_company_contacts');
  20.         $this->addSql('ALTER TABLE channel_company_contacts CHANGE contact_id channel_contact_id VARCHAR(36) NOT NULL');
  21.         $this->addSql('
  22.             UPDATE channel_company_contacts ccc
  23.             INNER JOIN channel_company cc ON cc.id = ccc.company_id
  24.             INNER JOIN channel_contacts chc 
  25.                 ON chc.contact_id = ccc.channel_contact_id
  26.                 AND chc.channel_id = cc.channel_id
  27.             SET ccc.channel_contact_id = chc.id
  28.         ');
  29.         $this->addSql('ALTER TABLE channel_company_contacts ADD CONSTRAINT FK_126D19A5516875DC FOREIGN KEY (channel_contact_id) REFERENCES channel_contacts (id) ON DELETE CASCADE');
  30.         $this->addSql('CREATE INDEX IDX_126D19A5516875DC ON channel_company_contacts (channel_contact_id)');
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.         // this down() migration is auto-generated, please modify it to your needs
  35.         $this->addSql('ALTER TABLE channel_company_contacts DROP FOREIGN KEY FK_126D19A5516875DC');
  36.         $this->addSql('DROP INDEX IDX_126D19A5516875DC ON channel_company_contacts');
  37.         $this->addSql('ALTER TABLE channel_company_contacts CHANGE channel_contact_id contact_id VARCHAR(36) NOT NULL');
  38.         $this->addSql('ALTER TABLE channel_company_contacts ADD CONSTRAINT FK_126D19A5E7A1254A FOREIGN KEY (contact_id) REFERENCES contacts (id) ON DELETE CASCADE');
  39.         $this->addSql('CREATE INDEX IDX_126D19A5E7A1254A ON channel_company_contacts (contact_id)');
  40.     }
  41. }