Skip to content

Wrong parse of search path for table in different schemas of PostgreSQL Builder. #41213

@Manriel

Description

@Manriel
  • Laravel Version: 9.0.x
  • PHP Version: not related with php version
  • Database Driver & Version: not related with driver

Description:

$this->connection->getConfig('search_path') ?: 'public'

I suppose that this one line should be like in other places of the same file:
$this->connection->getConfig('search_path') ?: $this->connection->getConfig('schema')

Otherwise, if you check table exists at postgres schema from env variable DB_SCHEMA referenced in the config, but it checks default postgres schema "public", ignoring the configuration.

Steps To Reproduce:

  1. Create table "migrations" at default postgres schema public
  2. Set env variable DB_SCHEMA with value different from "public" that do not contain any tables (the schema should exist at the DB, of course)
  3. Run command php artisan migrate.

You'll see that it will fail with error that it can't reference "migrations" table that not exist.
If you turn on SQL queries log, you'll see that it have checked table "migrations" in schema "public", found it exists and try to make a query to that table in schema you referenced at the env variable DB_SCHEMA that still does not exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions