Skip to content

Commit 920252e

Browse files
committed
fix: mysql schema diff
1 parent 77cd842 commit 920252e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/private/DB/MySQLMigrator.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424

2525
namespace OC\DB;
2626

27+
use Doctrine\DBAL\Platforms\MariaDBPlatform;
28+
use Doctrine\DBAL\Platforms\MySQLPlatform;
2729
use Doctrine\DBAL\Schema\Schema;
30+
use Doctrine\DBAL\Types\BlobType;
31+
use Doctrine\DBAL\Types\TextType;
2832

2933
class MySQLMigrator extends Migrator {
3034
/**
@@ -48,9 +52,26 @@ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $conn
4852
// identifiers need to be quoted for mysql
4953
foreach ($schemaDiff->changedTables as $tableDiff) {
5054
$tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
55+
$changedColumns = [];
5156
foreach ($tableDiff->changedColumns as $column) {
5257
$column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
58+
59+
# Bring back dbal 2.x behavior for default handling ... https://github.com/doctrine/dbal/pull/5332
60+
// Don't propagate default value changes for unsupported column types.
61+
$platform = $connection->getDatabasePlatform();
62+
if (
63+
$platform instanceof MySQLPlatform &&
64+
!($platform instanceof MariaDBPlatform) &&
65+
$column->hasDefaultChanged() &&
66+
\count($column->changedProperties) === 1 &&
67+
$column->fromColumn != null &&
68+
($column->fromColumn->getType() instanceof TextType || $column->fromColumn->getType() instanceof BlobType)
69+
) {
70+
continue;
71+
}
72+
$changedColumns []= $column;
5373
}
74+
$tableDiff->changedColumns = $changedColumns;
5475
}
5576

5677
return $schemaDiff;

0 commit comments

Comments
 (0)