run() public method

public run ( array $steps )
$steps array
Example #1
0
 /**
  * Run a list of updates
  * 
  * @param array $files
  */
 protected function runUpdates(array $files)
 {
     $steps = array();
     $config = $this->dbvc()->config;
     $checklist = new Checklist($this->getConsole()->getTextWriter());
     $db = $this->dbvc()->db();
     $this->writeln("Running updates for database '{$config->db->dbname}':", Colors::YELLOW);
     foreach ($files as $update => $file) {
         $file = $config->datadir . DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . $file;
         $message = "  {$update} ";
         if ($this->force) {
             $steps[$message] = function () use($db, $update, $file) {
                 try {
                     $db->run($file);
                 } catch (\Exception $e) {
                     return false;
                 }
                 $db->markUpdate($update);
                 return true;
             };
         } else {
             $steps[$message] = function () use($db, $update, $file) {
                 $db->run($file);
                 $db->markUpdate($update);
                 return true;
             };
         }
     }
     $checklist->run($steps);
 }