-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Filter 'public' schema from listSchemaNames #5600
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 behavior was fine up until 3.4.0, so probably the root cause is somewhere else. Could you implement a test that would pass prior to 3.4.0 and fails now? This change doesn't look right.
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.
I really do think the root cause is here and it was just simply not "important" before
doctrine/migrations#441
doctrine/migrations#1196 (comment)
#1110
#1188 (comment)
doctrine/orm#4777
(and yes my migrations in my projects contain all CREATE SCHEMA public in down migration for some years now, at least 2018 with even commit specifically deleting them from down migration which I think everyone was doing)
it becomes important with 3.4.0 because now the schema list is used by dbal for its "drop" component , so we now (3.4+) "correctly" drop schemas created by the application but as a side effect we incorrectly drop the
public
schema too.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.
and actually these problems to "
create schema public
is added in down migration" is specifically because of that faulty behaviourbecause if 'public' is reported in schema list but as nothing report it in the application as needing it (as you don't need to explicitly precise something is in public schema, not precising schema =
public
schema ) , then "up" would have deleted itBUT it was not reported by the stuff generating
DROP
, only the part generating "CREATE SCHEMA"I can see this behaviour for other schema as well
in my migration
Version20201111213025.php
I can seewhich fit the explanation above (i.e it generates "create" but not "drop" )
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.
Checking that
Schema\Schema::toDropSql
should not generate a "DROP SCHEMA public" ? would that be good for youthe core of the issue is "Do we agree that
public
is not to be touched by the application layer ?"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.
From #5596 (comment):
@allan-simon if that's the change that caused the regression, should the new builder be adjusted accordingly and not drop any schemas?
No. We need to address the root cause, not a particular symptom.
The public schema is just another schema alongside others. Why do you think the right behavior is to return all schemas except for specifically
public
? Note that this method may be used by other applications for different purposes, so changing its behavior to address a symptom of another issue sounds like a bad idea to me.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.
I recommend that those who are affected by the issue focus on providing the steps to reproduce it instead of making code changes. You can build a test project like it was done in #5572 or #5584 (comment).
I will not consider any related code changes until the issue is reproduced in an isolated environment.
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.
that's exactly what I mean, so we're aligned, so let's address it :)
the root cause is I disagree with your statement
The public schema is just another schema alongside others
-> no it is not. the public schema is the default schema provided by postgresql in any single installation of postgresql, the same as you already don't return "information_schema" and any namespace starting with
pg_
, why is public different from them ?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.
i already answered that :(
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.
no because then it will continue to want to create them (and we will continue to have bug report saying that doctrine migration etc. are trying to:
create schema public
in down migration without adrop schema public
in theup
migrationcreate schema my_application_specific_schema
in up migration without a drop indown
-> in both case you have up and down migration that needs to edited manually (I made a quick survey around my php friends who also use postgresql and all have said "ah yes i have been manually editing migration for the last 5 years to remove these sneaky create schema" , of course I don't have formal proof of that outside of the numerous github issue I've found and documented in my comment above )
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.
I don't have any issue with that, I will spend the time as soon as we agree (or reach a strong disagreement) on the state