Skip to content

Commit

Permalink
Merge pull request #5414 from morozov/deprecate-innodb-only-fk
Browse files Browse the repository at this point in the history
Deprecate ignoring foreign keys DDL on non-InnoDB MySQL
  • Loading branch information
morozov authored May 27, 2022
2 parents 7b85b8c + 837631d commit 568a34d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ awareness about deprecated code.
The `AbstractPlatform::supportsForeignKeyConstraints()` method has been deprecated. All platforms should support
foreign key constraints.

## Deprecated `AbstractPlatform::supportsForeignKeyConstraints()`.

Relying on the DBAL not generating DDL for foreign keys on MySQL engines other than InnoDB is deprecated.
Define foreign key constraints only if they are necessary.

## Deprecated `AbstractPlatform` methods exposing quote characters.

The `AbstractPlatform::getStringLiteralQuoteCharacter()` and `::getIdentifierQuoteCharacter()` methods
Expand Down
15 changes: 12 additions & 3 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,18 @@ protected function _getCreateTableSQL($name, array $columns, array $options = []
}

// Propagate foreign key constraints only for InnoDB.
if (isset($options['foreignKeys']) && $engine === 'INNODB') {
foreach ($options['foreignKeys'] as $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $name);
if (isset($options['foreignKeys'])) {
if ($engine === 'INNODB') {
foreach ($options['foreignKeys'] as $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $name);
}
} elseif (count($options['foreignKeys']) > 0) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pulls/5414',
'Relying on the DBAL not generating DDL for foreign keys on MySQL engines'
. ' other than InnoDB is deprecated. Define foreign key constraints only if they are necessary.'
);
}
}

Expand Down

0 comments on commit 568a34d

Please sign in to comment.