コード例 #1
0
ファイル: Migration.php プロジェクト: natedrake/fast-forward
 /**
  * Initial setup of an empty database
  *
  * @return bool True when a migration happened
  *
  * @throws \Exception
  */
 private function fromBlank()
 {
     $this->out->note('No database found. Setting up a fresh one.');
     $setupStatements = $this->getBlankStatements();
     $this->out->progressStart(count($setupStatements));
     foreach ($setupStatements as $key => $singleSql) {
         $singleSql = trim($singleSql);
         try {
             $statement = DBA::prepare($singleSql);
             $statement->execute();
         } catch (\PDOException $e) {
             $msg = 'SQL error: ' . $e->getMessage() . "\nWhile trying to execute:\n{$singleSql}";
             throw new \Exception($msg);
         }
         $this->out->progressAdvance();
     }
     $this->out->progressFinish();
     return true;
 }