Exemplo n.º 1
0
 /**
  * @throws \RuntimeException
  */
 protected function validate()
 {
     if ($this->adapter->hasTable($this->origin->getName()) && $this->adapter->hasTable($this->destination->getName())) {
         return;
     }
     throw new \RuntimeException("Table `{$this->origin->getName()}` and `{$this->destination->getName()}` must exist.");
 }
Exemplo n.º 2
0
 /**
  * @throws \RuntimeException
  */
 protected function validate()
 {
     if (!$this->adapter->hasTable($this->origin->getName())) {
         throw new \RuntimeException("Table `{$this->origin->getName()}` does not exists.");
     }
     if (!$this->adapter->hasTable($this->destination->getName())) {
         throw new \RuntimeException("Table `{$this->destination->getName()}` does not exists.");
     }
 }
Exemplo n.º 3
0
 /**
  * @return Table
  * @throws \RuntimeException
  */
 public function temporaryTable()
 {
     if ($this->destination) {
         return $this->destination;
     }
     $temporaryTableName = $this->temporaryTableName();
     if ($this->adapter->hasTable($temporaryTableName)) {
         throw new \RuntimeException("The table `{$temporaryTableName}` already exists.");
     }
     $this->getLogger()->info("Creating temporary table `{$temporaryTableName}` from `{$this->origin->getName()}`");
     $this->adapter->query("CREATE TABLE {$temporaryTableName} LIKE {$this->origin->getName()}");
     return new \Lhm\Table($temporaryTableName, [], $this->adapter);
 }
Exemplo n.º 4
0
 /**
  * Checks to see if a table exists.
  *
  * @param string $tableName Table Name
  * @return bool
  */
 public function hasTable($tableName)
 {
     return $this->adapter->hasTable($tableName);
 }