function up()
 {
     echo "Starting Migration Proc ...<BR>";
     //check if migration already had ran ...
     $migration = Migration::get()->filter('Name', $this->title)->first();
     $promo_code_type = isset($_REQUEST['promo_code_type']) ? intval($_REQUEST['promo_code_type']) : null;
     $promo_code_file = isset($_REQUEST['promo_code_file']) ? $_REQUEST['promo_code_file'] : null;
     if (is_null($promo_code_type)) {
         echo 'ERROR - promo_code_type param missing!';
         exit;
     }
     if (is_null($promo_code_file)) {
         echo 'ERROR - promo_code_file param missing!';
         exit;
     }
     $base_path = ASSETS_PATH;
     $file_path = $base_path . '/' . $promo_code_file;
     $type = explode(".", $file_path);
     if (!strtolower(end($type)) == 'csv') {
         echo 'ERROR - file hast not a csv extension!';
         exit;
     }
     if (!file_exists($file_path)) {
         echo sprintf('ERROR - %s file does not exists!', $file_path);
         exit;
     }
     $reader = new CSVReader($file_path);
     $row = 0;
     do {
         $line = $reader->getLine();
         if ($line) {
             ++$row;
             if ($row === 1) {
                 continue;
             }
             // skip header ...
             switch ($promo_code_type) {
                 case 1:
                     $type = 'ACCEPTED';
                     break;
                 case 2:
                     $type = 'ALTERNATE';
                     break;
             }
             $code = new SpeakerSummitRegistrationPromoCode();
             $code->Code = $line[0];
             $code->Type = $type;
             $code->SummitID = Summit::get_active()->ID;
             try {
                 $code->write();
             } catch (Exception $ex) {
                 SS_Log::log($ex->getMessage(), SS_Log::ERR);
             }
         }
     } while ($line);
     echo "Ending  Migration Proc ...<BR>";
 }
 /**
  * @param string   $filename
  * @param int      $election_id
  * @param DateTime $open_date
  * @param DateTime $close_date
  * @return array
  */
 public function ingestVotersForElection($filename, $election_id, DateTime $open_date, DateTime $close_date)
 {
     $election_repository = $this->election_repository;
     $foundation_member_repository = $this->foundation_member_repository;
     $vote_factory = $this->vote_factory;
     $vote_repository = $this->vote_repository;
     $voter_file_factory = $this->voter_file_factory;
     $voter_file_repository = $this->voter_file_repository;
     $election_factory = $this->election_factory;
     return $this->tx_manager->transaction(function () use($filename, $election_id, $open_date, $close_date, $election_repository, $foundation_member_repository, $vote_factory, $vote_repository, $voter_file_factory, $voter_file_repository, $election_factory) {
         if ($voter_file_repository->getByFileName($filename)) {
             throw new EntityAlreadyExistsException('VoterFile', sprintf('filename = %s', $filename));
         }
         $election = $election_repository->getById($election_id);
         if (!$election) {
             $election = $election_factory->build($election_id, $open_date, $close_date);
             $election_repository->add($election);
         }
         $reader = new CSVReader($filename);
         $line = false;
         $header = $reader->getLine();
         $count = 0;
         $not_processed = array();
         while ($line = $reader->getLine()) {
             $first_name = $line[1];
             $last_name = $line[2];
             $member_id = (int) $line[3];
             $member = $foundation_member_repository->getById($member_id);
             if (!$member) {
                 $member = $foundation_member_repository->getByCompleteName($first_name, $last_name);
             }
             if ($member && $member->isFoundationMember()) {
                 $vote = $vote_factory->buildVote($election, $member);
                 $vote_repository->add($vote);
                 $count++;
             } else {
                 array_push($not_processed, array('id' => $member_id, 'first_name' => $first_name, 'last_name' => $last_name));
             }
         }
         $voter_file = $voter_file_factory->build($filename);
         $voter_file_repository->add($voter_file);
         return array($count, $not_processed);
     });
 }