6 private $difference = [];
24 $compare->compareSequences($source, $target);
25 $compare->compareProcedures($source, $target);
26 $compare->compareTables($source, $target);
27 return $compare->difference;
38 private function compareSequences(
Schema $source,
Schema $target)
40 foreach ($source->sequences->compare($target->sequences) as $pair)
42 $this->difference[] = $pair;
54 private function compareProcedures(Schema $source, Schema $target)
56 foreach ($source->procedures->compare($target->procedures) as $pair)
58 $this->difference[] = $pair;
70 private function compareTables(Schema $source, Schema $target)
72 foreach ($source->tables->compare($target->tables,
false) as $pair)
74 if (isset($pair[0]) && isset($pair[1]))
76 $this->compareTable($pair[0], $pair[1]);
78 elseif (!isset($pair[0]) && isset($pair[1]))
80 $this->difference[] = $pair;
82 $emptyCollection =
new Collection;
83 foreach ($emptyCollection->compare($pair[1]->triggers) as $pair2)
85 $this->difference[] = $pair2;
90 $this->difference[] = $pair;
103 private function compareTable(Table $source, Table $target)
105 foreach ($source->columns->compare($target->columns) as $pair)
107 if (isset($pair[0]) && isset($pair[1]))
109 $this->compareColumn($pair[0], $pair[1]);
113 $this->difference[] = $pair;
116 foreach ($source->indexes->compare($target->indexes) as $pair)
118 $this->difference[] = $pair;
120 foreach ($source->constraints->compare($target->constraints) as $pair)
122 $this->difference[] = $pair;
124 foreach ($source->triggers->compare($target->triggers) as $pair)
126 $this->difference[] = $pair;
138 private function compareColumn(Column $source, Column $target)
141 $source->type !== $target->type
142 || $source->unsigned !== $target->unsigned
143 || $source->length !== $target->length
144 || $source->nullable !== $target->nullable
145 || $source->default !== $target->default
148 $this->difference[] = [$source, $target];