/** * Migrates the storage locations */ public function run() { $count = 0; $skipped = 0; $r = mysql_query("SELECT * FROM storeloc"); while ($store = mysql_fetch_assoc($r)) { $name = PartDBMigration::convertText($store["name"]); try { $storageLocation = StorageLocationManager::getInstance()->getStorageLocationByName($name); $skipped++; } catch (\Exception $e) { $oStorageLocation = new StorageLocation(); $oStorageLocation->setName($name); $this->entityManager->persist($oStorageLocation); $count++; } } $this->entityManager->flush(); $this->logMessage(sprintf("Migrated %d storage locations, skipped %d because they already exist", $count, $skipped)); }
/** * Migrates the existing distributors */ public function run() { $count = 0; $skipped = 0; $r = mysql_query("SELECT * FROM suppliers"); while ($supplier = mysql_fetch_assoc($r)) { $name = PartDBMigration::convertText($supplier["name"]); try { $distributor = DistributorManager::getInstance()->getDistributorByName($name); $skipped++; } catch (\Exception $e) { $distributor = new Distributor(); $distributor->setName($name); $this->entityManager->persist($distributor); $count++; } } $this->entityManager->flush(); $this->logMessage(sprintf("Migrated %d distributors, skipped %d because they already exist", $count, $skipped)); }
/** * Migrates the existing footprints */ public function run() { $count = 0; $skipped = 0; // Get or create node for the imported footprints $footprintCategory = FootprintSetup::addFootprintPath(explode("/", "Imported Footprints"), FootprintCategoryManager::getInstance()->getRootNode()); $r = mysql_query("SELECT * FROM footprints"); while ($sFootprint = mysql_fetch_assoc($r)) { $name = PartDBMigration::convertText($sFootprint["name"]); try { FootprintManager::getInstance()->getFootprintByName($name); $skipped++; } catch (\Exception $e) { $footprint = new Footprint(); $footprint->setName($name); $footprint->setCategory($footprintCategory->getNode()); $this->entityManager->persist($footprint); $count++; } } $this->entityManager->flush(); $this->logMessage(sprintf("Migrated %d footprints, skipped %d because they already exist", $count, $skipped)); }