Skip to content

Comments

Deprecate creation of empty namespaces#7186

Merged
morozov merged 1 commit intodoctrine:4.4.xfrom
morozov:deprecate-create-namespace
Oct 9, 2025
Merged

Deprecate creation of empty namespaces#7186
morozov merged 1 commit intodoctrine:4.4.xfrom
morozov:deprecate-create-namespace

Conversation

@morozov
Copy link
Member

@morozov morozov commented Oct 8, 2025

This is a prerequisite for fixing #7184.

Currently, there are two ways of creating a namespace in the Schema:

  1. Add a table or sequence with a qualified name. The namespace will be derived from the qualifier.
  2. Create a namespace manually.

At the same time, there is no way to drop a namespace from the Schema:

  1. Dropping the last object within a namespace doesn't automatically drop the namespace.
  2. There is no method that would allow dropping a namespace manually.

In 5.0.x, I will rework the internals of the Schema class such that tables and sequences will be indexed by their schema name (i.e. the namespace) and unqualified name. This way, listing the names of all namespaces in the schema will be as trivial as listing the top-level keys of this two-dimensional array.

Retaining the possibility of adding namespaces manually would require additional maintenance of the namespaces within the schema, while the deprecation of this behavior will allow fixing the issue mentioned above.

Rejected alternatives

Adding the possibility of manually dropping the namespace from the schema doesn't look like a good options because:

  1. It is not clear what the behavior should be when the namespace being dropped contains objects.
  2. Schema::toDropSql() doesn't drop the namespaces and AbstractPlatform::getAlterSchemaSQL() doesn't respect SchemaDiff::getDroppedNamespaces(), so even if the namespace exists, it will remain there even if it's dropped from the application-managed schema.

@morozov morozov added this to the 4.4.0 milestone Oct 8, 2025
@morozov morozov marked this pull request as ready for review October 9, 2025 08:05
@morozov morozov requested review from derrabus and greg0ire October 9, 2025 08:05
@morozov morozov merged commit 574651e into doctrine:4.4.x Oct 9, 2025
96 checks passed
@morozov morozov deleted the deprecate-create-namespace branch December 5, 2025 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants