Failed Conditions
Push — master ( c8e6c9...9f843b )
by Marco
11:13
created

Comparator::detectColumnRenamings()   C

Complexity

Conditions 7
Paths 16

Size

Total Lines 22
Code Lines 15

Duplication

Lines 22
Ratio 100 %

Code Coverage

Tests 15
CRAP Score 7

Importance

Changes 0
Metric Value
dl 22
loc 22
ccs 15
cts 15
cp 1
rs 6.9811
c 0
b 0
f 0
cc 7
eloc 15
nc 16
nop 1
crap 7
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\DBAL\Schema;
21
22
use Doctrine\DBAL\Types;
23
24
/**
25
 * Compares two Schemas and return an instance of SchemaDiff.
26
 *
27
 * @link   www.doctrine-project.org
28
 * @since  2.0
29
 * @author Benjamin Eberlei <[email protected]>
30
 */
31
class Comparator
32
{
33
    /**
34
     * @param \Doctrine\DBAL\Schema\Schema $fromSchema
35
     * @param \Doctrine\DBAL\Schema\Schema $toSchema
36
     *
37
     * @return \Doctrine\DBAL\Schema\SchemaDiff
38
     */
39 17
    public static function compareSchemas(Schema $fromSchema, Schema $toSchema)
40
    {
41 17
        $c = new self();
42
43 17
        return $c->compare($fromSchema, $toSchema);
44
    }
45
46
    /**
47
     * Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
48
     *
49
     * The returned differences are returned in such a way that they contain the
50
     * operations to change the schema stored in $fromSchema to the schema that is
51
     * stored in $toSchema.
52
     *
53
     * @param \Doctrine\DBAL\Schema\Schema $fromSchema
54
     * @param \Doctrine\DBAL\Schema\Schema $toSchema
55
     *
56
     * @return \Doctrine\DBAL\Schema\SchemaDiff
57
     */
58 27
    public function compare(Schema $fromSchema, Schema $toSchema)
59
    {
60 27
        $diff = new SchemaDiff();
61 27
        $diff->fromSchema = $fromSchema;
62
63 27
        $foreignKeysToTable = [];
64
65 27
        foreach ($toSchema->getNamespaces() as $namespace) {
66 2
            if ( ! $fromSchema->hasNamespace($namespace)) {
67 2
                $diff->newNamespaces[$namespace] = $namespace;
68
            }
69
        }
70
71 27
        foreach ($fromSchema->getNamespaces() as $namespace) {
72 2
            if ( ! $toSchema->hasNamespace($namespace)) {
73 2
                $diff->removedNamespaces[$namespace] = $namespace;
74
            }
75
        }
76
77 27
        foreach ($toSchema->getTables() as $table) {
78 21
            $tableName = $table->getShortestName($toSchema->getName());
79 21
            if ( ! $fromSchema->hasTable($tableName)) {
80 5
                $diff->newTables[$tableName] = $toSchema->getTable($tableName);
81
            } else {
82 19
                $tableDifferences = $this->diffTable($fromSchema->getTable($tableName), $toSchema->getTable($tableName));
83 19
                if ($tableDifferences !== false) {
84 21
                    $diff->changedTables[$tableName] = $tableDifferences;
85
                }
86
            }
87
        }
88
89
        /* Check if there are tables removed */
90 27
        foreach ($fromSchema->getTables() as $table) {
91 20
            $tableName = $table->getShortestName($fromSchema->getName());
92
93 20
            $table = $fromSchema->getTable($tableName);
94 20
            if ( ! $toSchema->hasTable($tableName)) {
95 5
                $diff->removedTables[$tableName] = $table;
96
            }
97
98
            // also remember all foreign keys that point to a specific table
99 20
            foreach ($table->getForeignKeys() as $foreignKey) {
100 2
                $foreignTable = strtolower($foreignKey->getForeignTableName());
101 2
                if (!isset($foreignKeysToTable[$foreignTable])) {
102 2
                    $foreignKeysToTable[$foreignTable] = [];
103
                }
104 20
                $foreignKeysToTable[$foreignTable][] = $foreignKey;
105
            }
106
        }
107
108 27
        foreach ($diff->removedTables as $tableName => $table) {
109 5
            if (isset($foreignKeysToTable[$tableName])) {
110 2
                $diff->orphanedForeignKeys = array_merge($diff->orphanedForeignKeys, $foreignKeysToTable[$tableName]);
111
112
                // deleting duplicated foreign keys present on both on the orphanedForeignKey
113
                // and the removedForeignKeys from changedTables
114 2
                foreach ($foreignKeysToTable[$tableName] as $foreignKey) {
115
                    // strtolower the table name to make if compatible with getShortestName
116 2
                    $localTableName = strtolower($foreignKey->getLocalTableName());
117 2
                    if (isset($diff->changedTables[$localTableName])) {
118 2
                        foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) {
119
                            // We check if the key is from the removed table if not we skip.
120 2
                            if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) {
121 1
                                continue;
122
                            }
123 5
                            unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]);
124
                        }
125
                    }
126
                }
127
            }
128
        }
129
130 27
        foreach ($toSchema->getSequences() as $sequence) {
131 4
            $sequenceName = $sequence->getShortestName($toSchema->getName());
132 4
            if ( ! $fromSchema->hasSequence($sequenceName)) {
133 3
                if ( ! $this->isAutoIncrementSequenceInSchema($fromSchema, $sequence)) {
134 3
                    $diff->newSequences[] = $sequence;
135
                }
136
            } else {
137 2
                if ($this->diffSequence($sequence, $fromSchema->getSequence($sequenceName))) {
138 4
                    $diff->changedSequences[] = $toSchema->getSequence($sequenceName);
139
                }
140
            }
141
        }
142
143 27
        foreach ($fromSchema->getSequences() as $sequence) {
144 4
            if ($this->isAutoIncrementSequenceInSchema($toSchema, $sequence)) {
145 1
                continue;
146
            }
147
148 3
            $sequenceName = $sequence->getShortestName($fromSchema->getName());
149
150 3
            if ( ! $toSchema->hasSequence($sequenceName)) {
151 3
                $diff->removedSequences[] = $sequence;
152
            }
153
        }
154
155 27
        return $diff;
156
    }
157
158
    /**
159
     * @param \Doctrine\DBAL\Schema\Schema   $schema
160
     * @param \Doctrine\DBAL\Schema\Sequence $sequence
161
     *
162
     * @return boolean
163
     */
164 6
    private function isAutoIncrementSequenceInSchema($schema, $sequence)
165
    {
166 6
        foreach ($schema->getTables() as $table) {
167 2
            if ($sequence->isAutoIncrementsFor($table)) {
168 2
                return true;
169
            }
170
        }
171
172 4
        return false;
173
    }
174
175
    /**
176
     * @param \Doctrine\DBAL\Schema\Sequence $sequence1
177
     * @param \Doctrine\DBAL\Schema\Sequence $sequence2
178
     *
179
     * @return boolean
180
     */
181 3
    public function diffSequence(Sequence $sequence1, Sequence $sequence2)
182
    {
183 3
        if ($sequence1->getAllocationSize() != $sequence2->getAllocationSize()) {
184 2
            return true;
185
        }
186
187 2
        if ($sequence1->getInitialValue() != $sequence2->getInitialValue()) {
188 1
            return true;
189
        }
190
191 1
        return false;
192
    }
193
194
    /**
195
     * Returns the difference between the tables $table1 and $table2.
196
     *
197
     * If there are no differences this method returns the boolean false.
198
     *
199
     * @param \Doctrine\DBAL\Schema\Table $table1
200
     * @param \Doctrine\DBAL\Schema\Table $table2
201
     *
202
     * @return boolean|\Doctrine\DBAL\Schema\TableDiff
203
     */
204 122
    public function diffTable(Table $table1, Table $table2)
205
    {
206 122
        $changes = 0;
207 122
        $tableDifferences = new TableDiff($table1->getName());
208 122
        $tableDifferences->fromTable = $table1;
209
210 122
        $table1Columns = $table1->getColumns();
211 122
        $table2Columns = $table2->getColumns();
212
213
        /* See if all the fields in table 1 exist in table 2 */
214 122
        foreach ($table2Columns as $columnName => $column) {
215 117
            if ( !$table1->hasColumn($columnName)) {
216 29
                $tableDifferences->addedColumns[$columnName] = $column;
217 117
                $changes++;
218
            }
219
        }
220
        /* See if there are any removed fields in table 2 */
221 122
        foreach ($table1Columns as $columnName => $column) {
222
            // See if column is removed in table 2.
223 117
            if ( ! $table2->hasColumn($columnName)) {
224 28
                $tableDifferences->removedColumns[$columnName] = $column;
225 28
                $changes++;
226 28
                continue;
227
            }
228
229
            // See if column has changed properties in table 2.
230 97
            $changedProperties = $this->diffColumn($column, $table2->getColumn($columnName));
231
232 97
            if ( ! empty($changedProperties)) {
233 42
                $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties);
234 42
                $columnDiff->fromColumn = $column;
235 42
                $tableDifferences->changedColumns[$column->getName()] = $columnDiff;
236 97
                $changes++;
237
            }
238
        }
239
240 122
        $this->detectColumnRenamings($tableDifferences);
241
242 122
        $table1Indexes = $table1->getIndexes();
243 122
        $table2Indexes = $table2->getIndexes();
244
245
        /* See if all the indexes in table 1 exist in table 2 */
246 122
        foreach ($table2Indexes as $indexName => $index) {
247 49
            if (($index->isPrimary() && $table1->hasPrimaryKey()) || $table1->hasIndex($indexName)) {
248 33
                continue;
249
            }
250
251 16
            $tableDifferences->addedIndexes[$indexName] = $index;
252 16
            $changes++;
253
        }
254
        /* See if there are any removed indexes in table 2 */
255 122
        foreach ($table1Indexes as $indexName => $index) {
256
            // See if index is removed in table 2.
257 46
            if (($index->isPrimary() && ! $table2->hasPrimaryKey()) ||
258 46
                ! $index->isPrimary() && ! $table2->hasIndex($indexName)
259
            ) {
260 17
                $tableDifferences->removedIndexes[$indexName] = $index;
261 17
                $changes++;
262 17
                continue;
263
            }
264
265
            // See if index has changed in table 2.
266 33
            $table2Index = $index->isPrimary() ? $table2->getPrimaryKey() : $table2->getIndex($indexName);
267
268 33
            if ($this->diffIndex($index, $table2Index)) {
0 ignored issues
show
Bug introduced by
It seems like $table2Index can also be of type null; however, parameter $index2 of Doctrine\DBAL\Schema\Comparator::diffIndex() does only seem to accept Doctrine\DBAL\Schema\Index, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

268
            if ($this->diffIndex($index, /** @scrutinizer ignore-type */ $table2Index)) {
Loading history...
269 15
                $tableDifferences->changedIndexes[$indexName] = $table2Index;
270 33
                $changes++;
271
            }
272
        }
273
274 122
        $this->detectIndexRenamings($tableDifferences);
275
276 122
        $fromFkeys = $table1->getForeignKeys();
277 122
        $toFkeys = $table2->getForeignKeys();
278
279 122
        foreach ($fromFkeys as $key1 => $constraint1) {
280 10
            foreach ($toFkeys as $key2 => $constraint2) {
281 4
                if ($this->diffForeignKey($constraint1, $constraint2) === false) {
282 1
                    unset($fromFkeys[$key1], $toFkeys[$key2]);
283
                } else {
284 3
                    if (strtolower($constraint1->getName()) == strtolower($constraint2->getName())) {
285 2
                        $tableDifferences->changedForeignKeys[] = $constraint2;
286 2
                        $changes++;
287 10
                        unset($fromFkeys[$key1], $toFkeys[$key2]);
288
                    }
289
                }
290
            }
291
        }
292
293 122
        foreach ($fromFkeys as $constraint1) {
294 7
            $tableDifferences->removedForeignKeys[] = $constraint1;
295 7
            $changes++;
296
        }
297
298 122
        foreach ($toFkeys as $constraint2) {
299 2
            $tableDifferences->addedForeignKeys[] = $constraint2;
300 2
            $changes++;
301
        }
302
303 122
        return $changes ? $tableDifferences : false;
304
    }
305
306
    /**
307
     * Try to find columns that only changed their name, rename operations maybe cheaper than add/drop
308
     * however ambiguities between different possibilities should not lead to renaming at all.
309
     *
310
     * @param \Doctrine\DBAL\Schema\TableDiff $tableDifferences
311
     *
312
     * @return void
313
     */
314 122 View Code Duplication
    private function detectColumnRenamings(TableDiff $tableDifferences)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
315
    {
316 122
        $renameCandidates = [];
317 122
        foreach ($tableDifferences->addedColumns as $addedColumnName => $addedColumn) {
318 29
            foreach ($tableDifferences->removedColumns as $removedColumn) {
319 22
                if (count($this->diffColumn($addedColumn, $removedColumn)) == 0) {
320 29
                    $renameCandidates[$addedColumn->getName()][] = [$removedColumn, $addedColumn, $addedColumnName];
321
                }
322
            }
323
        }
324
325 122
        foreach ($renameCandidates as $candidateColumns) {
326 22
            if (count($candidateColumns) == 1) {
327 21
                list($removedColumn, $addedColumn) = $candidateColumns[0];
328 21
                $removedColumnName = strtolower($removedColumn->getName());
329 21
                $addedColumnName = strtolower($addedColumn->getName());
330
331 21
                if ( ! isset($tableDifferences->renamedColumns[$removedColumnName])) {
332 21
                    $tableDifferences->renamedColumns[$removedColumnName] = $addedColumn;
333
                    unset(
334 21
                        $tableDifferences->addedColumns[$addedColumnName],
335 22
                        $tableDifferences->removedColumns[$removedColumnName]
336
                    );
337
                }
338
            }
339
        }
340 122
    }
341
342
    /**
343
     * Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop
344
     * however ambiguities between different possibilities should not lead to renaming at all.
345
     *
346
     * @param \Doctrine\DBAL\Schema\TableDiff $tableDifferences
347
     *
348
     * @return void
349
     */
350 122 View Code Duplication
    private function detectIndexRenamings(TableDiff $tableDifferences)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
351
    {
352 122
        $renameCandidates = [];
353
354
        // Gather possible rename candidates by comparing each added and removed index based on semantics.
355 122
        foreach ($tableDifferences->addedIndexes as $addedIndexName => $addedIndex) {
356 16
            foreach ($tableDifferences->removedIndexes as $removedIndex) {
357 7
                if (! $this->diffIndex($addedIndex, $removedIndex)) {
358 16
                    $renameCandidates[$addedIndex->getName()][] = [$removedIndex, $addedIndex, $addedIndexName];
359
                }
360
            }
361
        }
362
363 122
        foreach ($renameCandidates as $candidateIndexes) {
364
            // If the current rename candidate contains exactly one semantically equal index,
365
            // we can safely rename it.
366
            // Otherwise it is unclear if a rename action is really intended,
367
            // therefore we let those ambiguous indexes be added/dropped.
368 3
            if (count($candidateIndexes) === 1) {
369 2
                list($removedIndex, $addedIndex) = $candidateIndexes[0];
370
371 2
                $removedIndexName = strtolower($removedIndex->getName());
372 2
                $addedIndexName = strtolower($addedIndex->getName());
373
374 2
                if (! isset($tableDifferences->renamedIndexes[$removedIndexName])) {
375 2
                    $tableDifferences->renamedIndexes[$removedIndexName] = $addedIndex;
376
                    unset(
377 2
                        $tableDifferences->addedIndexes[$addedIndexName],
378 3
                        $tableDifferences->removedIndexes[$removedIndexName]
379
                    );
380
                }
381
            }
382
        }
383 122
    }
384
385
    /**
386
     * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key1
387
     * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key2
388
     *
389
     * @return boolean
390
     */
391 7
    public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
392
    {
393 7
        if (array_map('strtolower', $key1->getUnquotedLocalColumns()) != array_map('strtolower', $key2->getUnquotedLocalColumns())) {
394 1
            return true;
395
        }
396
397 6
        if (array_map('strtolower', $key1->getUnquotedForeignColumns()) != array_map('strtolower', $key2->getUnquotedForeignColumns())) {
398
            return true;
399
        }
400
401 6
        if ($key1->getUnqualifiedForeignTableName() !== $key2->getUnqualifiedForeignTableName()) {
402 1
            return true;
403
        }
404
405 5
        if ($key1->onUpdate() != $key2->onUpdate()) {
406 1
            return true;
407
        }
408
409 4
        if ($key1->onDelete() != $key2->onDelete()) {
410
            return true;
411
        }
412
413 4
        return false;
414
    }
415
416
    /**
417
     * Returns the difference between the fields $field1 and $field2.
418
     *
419
     * If there are differences this method returns $field2, otherwise the
420
     * boolean false.
421
     *
422
     * @param \Doctrine\DBAL\Schema\Column $column1
423
     * @param \Doctrine\DBAL\Schema\Column $column2
424
     *
425
     * @return array
426
     */
427 139
    public function diffColumn(Column $column1, Column $column2)
428
    {
429 139
        $properties1 = $column1->toArray();
430 139
        $properties2 = $column2->toArray();
431
432 139
        $changedProperties = [];
433
434 139
        foreach (['type', 'notnull', 'unsigned', 'autoincrement'] as $property) {
435 139
            if ($properties1[$property] != $properties2[$property]) {
436 139
                $changedProperties[] = $property;
437
            }
438
        }
439
440
        // This is a very nasty hack to make comparator work with the legacy json_array type, which should be killed in v3
441 139
        if ($this->isALegacyJsonComparison($properties1['type'], $properties2['type'])) {
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\DBAL\Schema\Com...ALegacyJsonComparison() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

441
        if (/** @scrutinizer ignore-deprecated */ $this->isALegacyJsonComparison($properties1['type'], $properties2['type'])) {
Loading history...
442 1
            array_shift($changedProperties);
443
444 1
            $changedProperties[] = 'comment';
445
        }
446
447 139
        if ($properties1['default'] != $properties2['default'] ||
448
            // Null values need to be checked additionally as they tell whether to create or drop a default value.
449
            // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
450 136
            (null === $properties1['default'] && null !== $properties2['default']) ||
451 139
            (null === $properties2['default'] && null !== $properties1['default'])
452
        ) {
453 4
            $changedProperties[] = 'default';
454
        }
455
456 139
        if (($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) ||
457 139
            $properties1['type'] instanceof Types\BinaryType
458
        ) {
459
            // check if value of length is set at all, default value assumed otherwise.
460 28
            $length1 = $properties1['length'] ?: 255;
461 28
            $length2 = $properties2['length'] ?: 255;
462 28
            if ($length1 != $length2) {
463 13
                $changedProperties[] = 'length';
464
            }
465
466 28
            if ($properties1['fixed'] != $properties2['fixed']) {
467 28
                $changedProperties[] = 'fixed';
468
            }
469 122
        } elseif ($properties1['type'] instanceof Types\DecimalType) {
470 2
            if (($properties1['precision'] ?: 10) != ($properties2['precision'] ?: 10)) {
471
                $changedProperties[] = 'precision';
472
            }
473 2
            if ($properties1['scale'] != $properties2['scale']) {
474
                $changedProperties[] = 'scale';
475
            }
476
        }
477
478
        // A null value and an empty string are actually equal for a comment so they should not trigger a change.
479 139
        if ($properties1['comment'] !== $properties2['comment'] &&
480 139
            ! (null === $properties1['comment'] && '' === $properties2['comment']) &&
481 139
            ! (null === $properties2['comment'] && '' === $properties1['comment'])
482
        ) {
483 45
            $changedProperties[] = 'comment';
484
        }
485
486 139
        $customOptions1 = $column1->getCustomSchemaOptions();
487 139
        $customOptions2 = $column2->getCustomSchemaOptions();
488
489 139
        foreach (array_merge(array_keys($customOptions1), array_keys($customOptions2)) as $key) {
490 2
            if ( ! array_key_exists($key, $properties1) || ! array_key_exists($key, $properties2)) {
491 1
                $changedProperties[] = $key;
492 2
            } elseif ($properties1[$key] !== $properties2[$key]) {
493 2
                $changedProperties[] = $key;
494
            }
495
        }
496
497 139
        $platformOptions1 = $column1->getPlatformOptions();
498 139
        $platformOptions2 = $column2->getPlatformOptions();
499
500 139
        foreach (array_keys(array_intersect_key($platformOptions1, $platformOptions2)) as $key) {
501 2
            if ($properties1[$key] !== $properties2[$key]) {
502 2
                $changedProperties[] = $key;
503
            }
504
        }
505
506 139
        return array_unique($changedProperties);
507
    }
508
509
    /**
510
     * TODO: kill with fire on v3.0
511
     *
512
     * @deprecated
513
     */
514 139
    private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : bool
515
    {
516 139
        if ( ! $one instanceof Types\JsonType || ! $other instanceof Types\JsonType) {
517 137
            return false;
518
        }
519
520 2
        return ( ! $one instanceof Types\JsonArrayType && $other instanceof Types\JsonArrayType)
521 2
            || ( ! $other instanceof Types\JsonArrayType && $one instanceof Types\JsonArrayType);
522
    }
523
524
    /**
525
     * Finds the difference between the indexes $index1 and $index2.
526
     *
527
     * Compares $index1 with $index2 and returns $index2 if there are any
528
     * differences or false in case there are no differences.
529
     *
530
     * @param \Doctrine\DBAL\Schema\Index $index1
531
     * @param \Doctrine\DBAL\Schema\Index $index2
532
     *
533
     * @return boolean
534
     */
535 40
    public function diffIndex(Index $index1, Index $index2)
536
    {
537 40
        if ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)) {
538 21
            return false;
539
        }
540
541 19
        return true;
542
    }
543
}
544