migrations/Version20220223095634.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 Version20220223095634 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("UPDATE manufacturer 
  18.                                 LEFT JOIN ( 
  19.                                     SELECT manufacturer_id, COUNT(q.status) AS finishedCount
  20.                                     FROM price_inquiry                            
  21.                                     INNER JOIN customer_quotations AS q
  22.                                         ON q.id = price_inquiry.quotation_id
  23.                                         WHERE q.status = 'quotation.status.finished'    
  24.                                         AND order_price is NOT null
  25.                                     GROUP BY manufacturer_id
  26.                                 ) as p ON 
  27.                                     p.manufacturer_id = manufacturer.id
  28.                                     
  29.                                     SET manufacturer.order_count = ifnull(p.finishedCount,0)
  30.                             ");
  31.     }
  32.     public function down(Schema $schema): void
  33.     {
  34.     }
  35. }