/** * Generate subpart of raport for triggers of table. * * @param string $table * @return array */ private function diffTriggers($table) { $sourceTable = $this->adapter('source')->table($table); $targetTable = $this->adapter('target')->table($table); $sourceTriggers = $sourceTable->triggers(); $targetTriggers = $targetTable->triggers(); $baseDiff = $this->baseDiff($sourceTriggers, $targetTriggers); $diff = $baseDiff['diff']; $status = $baseDiff['status']; foreach ($diff as $trigger => &$diffTrigger) { if ($diffTrigger['status'] != self::NO_CHANGE) { continue; } $sourceTrigger = $sourceTable->trigger($trigger); $targetTrigger = $targetTable->trigger($trigger); foreach (Trigger::allAttributes() as $attribute) { $sourceAttribute = $sourceTrigger->{$attribute}(); $targetAttribute = $targetTrigger->{$attribute}(); if ($sourceAttribute == Column::NOT_SUPPORTED || $targetAttribute == Column::NOT_SUPPORTED) { continue; } if ($attribute == Trigger::ATTRIBUTE_STATEMENT) { $sourceAttribute = preg_replace('/\\s+/', '', $sourceAttribute); $targetAttribute = preg_replace('/\\s+/', '', $targetAttribute); } if ($sourceAttribute !== $targetAttribute) { $diffTrigger['status'] = $status = self::CHANGED; $diffTrigger['diff'][$attribute] = array('source' => $sourceAttribute, 'target' => $targetAttribute); } } } return array('diff' => $diff, 'status' => $status); }
public function drop(MidataTrigger $trigger) { $name = $trigger->name(); return "DROP TRIGGER IF EXISTS `{$name}`;"; }