Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create migration: The namespace with name "public" already exists. #1476

Open
wants to merge 2 commits into
base: 3.8.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Generator/DiffGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
! method_exists($this->schemaManager, 'getSchemaSearchPaths')
&& $this->platform->supportsSchemas()
) {
$defaultNamespace = $toSchema->getName();
$defaultNamespace = $toSchema->getNamespaceName() ?? '';

Check warning on line 73 in src/Generator/DiffGenerator.php

View check run for this annotation

Codecov / codecov/patch

src/Generator/DiffGenerator.php#L73

Added line #L73 was not covered by tests
Copy link
Member

@morozov morozov Dec 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. The schema is the namespace for its tables. The schema itself cannot be associated with a namespace (only tables, views and sequences can). Currently it's possible to call getNamespaceName() on any AbstractAsset (which is a design flaw) but in DBAL 5, it will be possible only with the objects mentioned earlier.

The only situation in which currently a schema can be associated with a namespace is when its name contains a dot and the name isn't quoted (which is also a flaw and shouldn't be allowed).

if ($defaultNamespace !== '') {
$toSchema->createNamespace($defaultNamespace);
}
Expand Down