Esempio n. 1
0
 /**
  * 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;
 }