Ejemplo 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.");
 }
Ejemplo n.º 2
0
 /**
  * @param integer $lowest
  * @param integer $highest
  * @return string
  */
 protected function copy($lowest, $highest)
 {
     $originName = $this->adapter->quoteTableName($this->origin->getName());
     $destinationName = $this->adapter->quoteTableName($this->destination->getName());
     $destinationColumns = implode(',', $this->sqlHelper->quoteColumns($this->intersection->destination()));
     $originColumns = implode(',', $this->sqlHelper->typedColumns($originName, $this->sqlHelper->quoteColumns($this->intersection->origin())));
     return implode(" ", ["INSERT IGNORE INTO {$destinationName} ({$destinationColumns})", "SELECT {$originColumns} FROM {$originName}", "WHERE {$originName}.{$this->primaryKey} BETWEEN {$lowest} AND {$highest}"]);
 }
Ejemplo n.º 3
0
 /**
  * Returns the temporary table name.
  * @return string
  */
 public function temporaryTableName()
 {
     return "lhmn_{$this->origin->getName()}";
 }
Ejemplo n.º 4
0
 public function testItRenamesDestinationToOrigin()
 {
     $this->assertTrue($this->adapter->hasTable($this->destination->getName()));
     $this->switcher->run();
     $this->assertFalse($this->adapter->hasTable($this->destination->getName()));
 }
Ejemplo n.º 5
0
 /**
  * @param string $type
  * @return string
  */
 protected function trigger($type)
 {
     return "lhmt_{$type}_{$this->origin->getName()}";
 }