/** * @return string */ protected function createDeleteTrigger() { $name = $this->trigger('delete'); $primaryKey = $this->sqlHelper->extractPrimaryKey($this->origin); if (empty($primaryKey)) { throw new \RuntimeException("Table `{$this->origin->getName()}` does not have a primary key."); } $primaryKey = $this->sqlHelper->quoteColumn($primaryKey); $originName = $this->adapter->quoteTableName($this->origin->getName()); $destinationName = $this->adapter->quoteTableName($this->destination->getName()); return implode("\n ", ["CREATE TRIGGER {$name}", "AFTER DELETE ON {$originName} FOR EACH ROW", "DELETE IGNORE FROM {$destinationName} {$this->sqlHelper->annotation()}", "WHERE {$destinationName}.{$primaryKey} = OLD.{$primaryKey}"]); }
public function testAnnotation() { $this->assertEquals("/* large hadron migration (php) */", $this->helper->annotation()); }