-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.3] Fix support for multi-schema search_path in Postgres #15535
Conversation
What is the purpose of using an array for the schema in your configuration file? |
Can you explain more about why the array would be used in the first place... is it supposed to fall back to the second schema? |
Yes, it's basically a fallback as it sets the
In 5.0 this used to work without an array but sometime before 5.1 it was modified due to issues with improper quoting and was later transformed to take an array which seems to work ok now, apart from the migration issues that are addressed with this pull request. |
So wouldn't the proper behavior be for it to check each schema in this case - not just the first one? |
I think that actually depends on the use case: Use Case 1 You want to check if a table exists in the specified Use Case 2 You do migrations and want to be able to create a table with the same name in multiple schemas. For example in a multi-tenant app, where each tenant has it's own schema and there's also a My use case is actually the second one as I don't need to know if the table exists in other schemas since migrations are always performed in the primary schema (the first one). Also, based on the feedback from other users on #8639 it seems they also had similar use cases. One possible solution to cover both use cases would probably be for Let me know your thoughts on this and I can look into updating this pull request with such changes. |
I'll merge this for now and we'll see if the other use case arises. |
Following my bug report from #8639, the PostgresConnector class was modified to support a multi-schema
search_path
if the connection'sschema
configuration value is an array, e.g.That fix does correctly set the
search_path
to the specified one but using an array instead of a string for the schema now produces an error in artisan migrations.Running
php artisan migrate
now trows the following:The fix submitted with this pull request addresses this issue by using the first schema specified in the
schema
configuration array as the default schema for artisan migrations.Users are still able to override this default schema if needed by specifying the schema in the
migrations
configuration options:or by specifying a schema in the actual migration script: