summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Platforms/SQLite
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Platforms/SQLite')
-rw-r--r--vendor/doctrine/dbal/src/Platforms/SQLite/Comparator.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Platforms/SQLite/Comparator.php b/vendor/doctrine/dbal/src/Platforms/SQLite/Comparator.php
new file mode 100644
index 0000000..f27e1b4
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Platforms/SQLite/Comparator.php
@@ -0,0 +1,52 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Platforms\SQLite;
6
7use Doctrine\DBAL\Platforms\SQLitePlatform;
8use Doctrine\DBAL\Schema\Comparator as BaseComparator;
9use Doctrine\DBAL\Schema\Table;
10use Doctrine\DBAL\Schema\TableDiff;
11
12use function strcasecmp;
13
14/**
15 * Compares schemas in the context of SQLite platform.
16 *
17 * BINARY is the default column collation and should be ignored if specified explicitly.
18 */
19class Comparator extends BaseComparator
20{
21 /** @internal The comparator can be only instantiated by a schema manager. */
22 public function __construct(SQLitePlatform $platform)
23 {
24 parent::__construct($platform);
25 }
26
27 public function compareTables(Table $oldTable, Table $newTable): TableDiff
28 {
29 return parent::compareTables(
30 $this->normalizeColumns($oldTable),
31 $this->normalizeColumns($newTable),
32 );
33 }
34
35 private function normalizeColumns(Table $table): Table
36 {
37 $table = clone $table;
38
39 foreach ($table->getColumns() as $column) {
40 $options = $column->getPlatformOptions();
41
42 if (! isset($options['collation']) || strcasecmp($options['collation'], 'binary') !== 0) {
43 continue;
44 }
45
46 unset($options['collation']);
47 $column->setPlatformOptions($options);
48 }
49
50 return $table;
51 }
52}