Skip to content

Commit 574651e

Browse files
authored
Merge pull request #7186 from morozov/deprecate-create-namespace
Deprecate creation of empty namespaces
2 parents d043a8a + b257b8a commit 574651e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ awareness about deprecated code.
88

99
# Upgrade to 4.4
1010

11+
## Deprecated `Schema::createNamespace()` and the `$namespaces` constructor parameter
12+
13+
The `Schema::createNamespace()` method and the `$namespaces` constructor parameter have been deprecated. The schema
14+
automatically derives namespace names from the names of its tables and sequences. Creating empty namespaces is
15+
deprecated.
16+
1117
## Deprecated `TableDiff::getDroppedForeignKeys()`
1218

1319
The `TableDiff::getDroppedForeignKeys()` method has been deprecated. Use

src/Schema/Schema.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ public function __construct(
8989
?SchemaConfig $schemaConfig = null,
9090
array $namespaces = [],
9191
) {
92+
if (count($namespaces) > 0) {
93+
Deprecation::triggerIfCalledFromOutside(
94+
'doctrine/dbal',
95+
'https://github.com/doctrine/dbal/pull/7186',
96+
'Passing the $namespaces argument to the Schema constructor is deprecated.',
97+
);
98+
}
99+
92100
$schemaConfig ??= new SchemaConfig();
93101

94102
$this->_schemaConfig = $schemaConfig;
@@ -352,10 +360,21 @@ public function getSequences(): array
352360
/**
353361
* Creates a new namespace.
354362
*
363+
* @deprecated The schema automatically derives namespaces from the names of its tables and sequences.
364+
* Creating empty namespaces is deprecated.
365+
*
355366
* @return $this
356367
*/
357368
public function createNamespace(string $name): self
358369
{
370+
Deprecation::triggerIfCalledFromOutside(
371+
'doctrine/dbal',
372+
'https://github.com/doctrine/dbal/pull/7186',
373+
'%s is deprecated. The schema automatically derives namespaces from the names of its tables and'
374+
. ' sequences. Creating empty namespaces is deprecated.',
375+
__METHOD__,
376+
);
377+
359378
$unquotedName = strtolower($this->getUnquotedAssetName($name));
360379

361380
if (isset($this->namespaces[$unquotedName])) {

0 commit comments

Comments
 (0)