Version20151002183125.php (835B)
1 <?php 2 3 namespace PartKeepr\CoreBundle\DoctrineMigrations; 4 5 use Doctrine\DBAL\Schema\Schema; 6 7 /** 8 * Re-saves all parts in order to re-generate the averagePrice and removals field. 9 */ 10 class Version20151002183125 extends BaseMigration 11 { 12 /** 13 * @param Schema $schema 14 */ 15 public function up(Schema $schema) 16 { 17 $this->performDatabaseUpgrade(); 18 19 $partRepository = $this->getEM()->getRepository( 20 'PartKeeprPartBundle:Part' 21 ); 22 23 $parts = $partRepository->findAll(); 24 25 foreach ($parts as $part) { 26 $part->recomputeStockLevels(); 27 } 28 29 $this->getEM()->flush(); 30 } 31 32 /** 33 * @param Schema $schema 34 */ 35 public function down(Schema $schema) 36 { 37 // this down() migration is auto-generated, please modify it to your needs 38 } 39 }