Skip to content

Commit

Permalink
Merge pull request #487 from havvg/hotfix/fk-migrations
Browse files Browse the repository at this point in the history
migrations don't report equal FK behavior
  • Loading branch information
willdurand committed Oct 22, 2012
2 parents 51983e4 + 04e6a7c commit 65def77
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions generator/lib/model/diff/PropelForeignKeyComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,22 @@ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseIn
return true;
}

// compare on
if ($fromFk->normalizeFKey($fromFk->getOnUpdate()) != $toFk->normalizeFKey($toFk->getOnUpdate())) {

/*
* Compare onDelete and onUpdate:
*
* "RESTRICT" and its synonym "NO ACTION" is default and is not being reported explicitly.
*/
$equalBehavior = array('', 'RESTRICT', 'NO ACTION');

$fromOnUpdate = strtoupper($fromFk->normalizeFKey($fromFk->getOnUpdate()));
$toOnUpdate = strtoupper($toFk->normalizeFKey($toFk->getOnUpdate()));
if ((in_array($fromOnUpdate, $equalBehavior) && !in_array($toOnUpdate, $equalBehavior)) || (!in_array($fromOnUpdate, $equalBehavior) && in_array($toOnUpdate, $equalBehavior))) {
return true;
}
if ($fromFk->normalizeFKey($fromFk->getOnDelete()) != $toFk->normalizeFKey($toFk->getOnDelete())) {
$fromOnDelete = strtoupper($fromFk->normalizeFKey($fromFk->getOnDelete()));
$toOnDelete = strtoupper($toFk->normalizeFKey($toFk->getOnDelete()));
if ((in_array($fromOnDelete, $equalBehavior) && !in_array($toOnDelete, $equalBehavior)) || (!in_array($fromOnDelete, $equalBehavior) && in_array($toOnDelete, $equalBehavior))) {
return true;
}

Expand Down

0 comments on commit 65def77

Please sign in to comment.