Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
81.25% |
13 / 16 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
comparator | |
81.25% |
13 / 16 |
|
0.00% |
0 / 1 |
9.53 | |
0.00% |
0 / 1 |
diffTable | |
81.25% |
13 / 16 |
|
0.00% |
0 / 1 |
9.53 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\db\doctrine; |
15 | |
16 | use Doctrine\DBAL\Schema\Table; |
17 | |
18 | class comparator extends \Doctrine\DBAL\Schema\Comparator |
19 | { |
20 | /** |
21 | * {@inerhitDoc} |
22 | */ |
23 | public function diffTable(Table $fromTable, Table $toTable) |
24 | { |
25 | $diff = parent::diffTable($fromTable, $toTable); |
26 | |
27 | if ($diff === false) |
28 | { |
29 | return false; |
30 | } |
31 | |
32 | if (!is_array($diff->changedColumns)) |
33 | { |
34 | return $diff; |
35 | } |
36 | |
37 | // When the type of a column changes, re-create the associated indices |
38 | foreach ($diff->changedColumns as $columnName => $changedColumn) |
39 | { |
40 | if (!$changedColumn->hasChanged('type')) |
41 | { |
42 | continue; |
43 | } |
44 | |
45 | foreach ($toTable->getIndexes() as $index_name => $index) |
46 | { |
47 | if (array_key_exists($index_name, $diff->addedIndexes) || array_key_exists($index_name, $diff->changedIndexes)) |
48 | { |
49 | continue; |
50 | } |
51 | |
52 | $index_columns = array_map('strtolower', $index->getUnquotedColumns()); |
53 | if (!in_array($columnName, $index_columns, true)) |
54 | { |
55 | continue; |
56 | } |
57 | |
58 | $diff->changedIndexes[$index_name] = $index; |
59 | } |
60 | } |
61 | |
62 | return $diff; |
63 | } |
64 | } |