File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ awareness about deprecated code.
88
99# Upgrade to 4.4
1010
11+ ## Deprecated dropping unnamed constraints in SQLite
12+
13+ Passing unnamed foreign key constraints as part of the ` $droppedForeignKeys ` argument of the ` TableDiff ` constructor
14+ has been deprecated.
15+
1116## Deprecated overwriting foreign key constraints
1217
1318Adding a foreign key constraint with a name that matches an existing one, whether explicitly specified or
Original file line number Diff line number Diff line change @@ -56,6 +56,17 @@ public function __construct(
5656 );
5757 }
5858
59+ foreach ($ droppedForeignKeys as $ droppedForeignKey ) {
60+ if ($ droppedForeignKey ->getName () === '' ) {
61+ Deprecation::trigger (
62+ 'doctrine/dbal ' ,
63+ 'https://github.com/doctrine/dbal/pull/7143 ' ,
64+ 'Dropping a foreign key constraints without specifying its name is deprecated. ' ,
65+ );
66+ break ;
67+ }
68+ }
69+
5970 if (count ($ modifiedForeignKeys ) === 0 ) {
6071 return ;
6172 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Doctrine \DBAL \Tests \Schema ;
6+
7+ use Doctrine \DBAL \Schema \Column ;
8+ use Doctrine \DBAL \Schema \ForeignKeyConstraint ;
9+ use Doctrine \DBAL \Schema \Table ;
10+ use Doctrine \DBAL \Schema \TableDiff ;
11+ use Doctrine \DBAL \Types \Types ;
12+ use Doctrine \Deprecations \PHPUnit \VerifyDeprecations ;
13+ use PHPUnit \Framework \TestCase ;
14+
15+ class TableDiffTest extends TestCase
16+ {
17+ use VerifyDeprecations;
18+
19+ public function testCreateWithInvalidDroppedForeignKeyName (): void
20+ {
21+ $ table = Table::editor ()
22+ ->setUnquotedName ('t1 ' )
23+ ->setColumns (
24+ Column::editor ()
25+ ->setUnquotedName ('c1 ' )
26+ ->setTypeName (Types::INTEGER )
27+ ->create (),
28+ )
29+ ->create ();
30+
31+ $ droppedForeignKeys = ForeignKeyConstraint::editor ()
32+ ->setUnquotedReferencingColumnNames ('c1 ' )
33+ ->setUnquotedReferencedTableName ('t2 ' )
34+ ->setUnquotedReferencedColumnNames ('c1 ' )
35+ ->create ();
36+
37+ $ this ->expectDeprecationWithIdentifier ('https://github.com/doctrine/dbal/pull/7143 ' );
38+ new TableDiff ($ table , droppedForeignKeys: [$ droppedForeignKeys ]);
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments