<?php
declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240919124021 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this
->correct('AFTONCHEMI', 300)
->correct('ASWATSON01', 487)
->correct('CHEMTURACO', 114)
->correct('ECQUALITYL', 194)
->correct('GULFOILSUP', 1021)
->correct('RAIZENTRAD', 833)
->correct('SANKYOYUKA', 103)
;
}
private function correct(string $code, int $correct): self
{
$this->addSql('
UPDATE legal_entity e
JOIN legal_entity_billing_company c ON e.billing_company_id = c.id AND c.alpha_code = ?
SET e.billing_company_id = ?
', [$code, $correct]);
$this->addSql('
UPDATE legal_entity_order_invoice i
JOIN legal_entity_billing_company c ON i.billing_company_id = c.id AND c.alpha_code = ?
SET i.billing_company_id = ?
', [$code, $correct]);
$this->addSql('DELETE FROM legal_entity_billing_company WHERE alpha_code = ? AND id != ?', [
$code,
$correct,
]);
return $this;
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}