-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
base: 3.8.x
Are you sure you want to change the base?
Conversation
Error "The namespace with name "public" already exists." fixed.
Sorry but… what was wrong with this message, and under which circumstances does it occur? |
I updated Symfony 6.4 to 7.2 and Doctrine 2 to 3.3 yesterday. After this I tried to run commands like make:migration or doctrine:migration:diff. Any attempt to create migration ended with error: "The namespace with name "public" already exists". I debugged your code and found that a value of variable $defaultNamespace is setting with schema name. So as I understood, maybe mistaken, you tried to use schema name for namespace name. I don't know what is namespace in PostgreSQL, but changes that I published here made my application work. Sorry, but I can't make some reproduction for you, my project is private and not small at all. However, if necessary, I can share, for example, my doctrine configuration. |
And one more thing. I also tried to figure out my issue another way. I found the table "shemata" in the database "information_shema". I found record here with shema "public", and I checked that schema owner is the same user, that is used in Symfony. So, I had schema public already, but Doctrine tried to create another one when I tried to create some new migration. |
Regarding the confusion about "schema", I recommend you read this: https://github.com/doctrine/dbal/blob/c91166a91b8639a1d7bfe0f88bca0273bdbe9d2d/src/Schema/Schema.php#L21-L44 |
You are already using DBAL 4, right? |
Thanks for your explanation of namespaces in doctrine. It's clear, so my pull request seems wrong. My doctrine versions are:
|
If you are getting that error, then it must mean that in your case, |
Oh I see, this isn't an SQL error, this is a DBAL exception because you already have Reading the code, It seems we expect to either have |
Do any of your ORM mapping files/configuration mention |
No, I can't find anything. |
Well what you can do is start a brand new project with all the latest libraries, and using Postgres, and test that you don't have the issue, since people at #1415 (comment) say it works for them. If you don't reproduce the issue, use your debugger on the new project to see how exactly the variables differ from what you have in your project, in particular You could also start from https://github.com/greg0ire/sample-pg-app |
OK, thanks for your help. I'll try to do that a little later. |
Can we please find a meaningful title for this PR? Thanks. |
Done. |
@@ -70,7 +70,7 @@ static function ($assetName) use ($filterExpression) { | |||
! method_exists($this->schemaManager, 'getSchemaSearchPaths') | |||
&& $this->platform->supportsSchemas() | |||
) { | |||
$defaultNamespace = $toSchema->getName(); | |||
$defaultNamespace = $toSchema->getNamespaceName() ?? ''; |
There was a problem hiding this comment.
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).
fix: unable to make migration on Postgres
Error message "The namespace with name "public" already exists." on d:m:diff or migration:make fixed.