/** * @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."); }
/** * @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."); } }
/** * @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); }
/** * Checks to see if a table exists. * * @param string $tableName Table Name * @return bool */ public function hasTable($tableName) { return $this->adapter->hasTable($tableName); }