<?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 Version20220223095634 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("UPDATE manufacturer
LEFT JOIN (
SELECT manufacturer_id, COUNT(q.status) AS finishedCount
FROM price_inquiry
INNER JOIN customer_quotations AS q
ON q.id = price_inquiry.quotation_id
WHERE q.status = 'quotation.status.finished'
AND order_price is NOT null
GROUP BY manufacturer_id
) as p ON
p.manufacturer_id = manufacturer.id
SET manufacturer.order_count = ifnull(p.finishedCount,0)
");
}
public function down(Schema $schema): void
{
}
}