Skip to content

[9.x] Replace schema with search_path in pgsql config #5726

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

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

cbj4074
Copy link
Contributor

@cbj4074 cbj4074 commented Nov 16, 2021

Per laravel/framework#35588 , the term "schema" (a namespace) has been corrected to "search_path" (a list of namespaces), where appropriate, throughout the framework.

Accordingly, the schema configuration key should be changed to search_path to better reflect the fact that it may specify a list of schemata (schemas), and not just a single schema. (In several Laravel versions prior to 9.0, the schema key could already specify more than one schema, but this fact was undocumented and non-obvious without examining the implementation carefully.)

As of Laravel 9.0, the search_path may specify any number of schemata, in any of the following formats:

'search_path' => 'public',
'search_path' => 'public,laravel',
'search_path' => ['public', '"laravel"', "'foobar'", '$bat'],
'search_path' => ''public', "laravel", "'foobar'", '$bat'',
'search_path' => '"$user", public',

Note that in the last example, the $user variable refers to PostgreSQL's special $user variable, as described in the Schema Documentation ( https://www.postgresql.org/docs/current/ddl-schemas.html ).

Note also that Laravel's default search_path value, 'public', is not necessarily the best choice for every use case. Developers should consult the "Usage Patterns" section of the aforementioned documentation before deciding how best to set the search_path, as it has security implications.

Per laravel/framework#35588 , the term "schema" (a namespace) has been corrected to "search_path" (a list of namespaces), where appropriate, throughout the framework.

Accordingly, the `schema` configuration key should be changed to `search_path` to better reflect the fact that it may specify a _list_ of schemata (schemas), and not just a single schema. (In several Laravel versions prior to 9.0, the `schema` key could already specify more than one schema, but this fact was undocumented and non-obvious without examining the implementation carefully.)

As of Laravel 9.0, the `search_path` may specify any number of schemata, in any of the following formats:

'search_path' => 'public',
'search_path' => 'public,laravel',
'search_path' => ['public', '"laravel"', "'foobar'", '$bat'],
'search_path' => '\'public\', "laravel", "\'foobar\'", \'$bat\'',
'search_path' => '"$user", public',

Note that in the last example, the `$user` variable refers to PostgreSQL's special $user variable, as described in the Schema Documentation ( https://www.postgresql.org/docs/current/ddl-schemas.html ).

Note also that Laravel's default `search_path` value, 'public', is not necessarily the best choice for every use case. Developers should consult the "Usage Patterns" section of the aforementioned documentation before deciding how best to set the `search_path`, as it has security implications.
@taylorotwell taylorotwell merged commit 195a7e0 into laravel:master Nov 16, 2021
@GrahamCampbell GrahamCampbell changed the title Replace schema with search_path in pgsql config [9.x] Replace schema with search_path in pgsql config Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants