Skip to content

Database tables of a selected plugin are not listed correctly #385

@uematsusoft

Description

@uematsusoft

In a OctoberCMS v4 with Builder Plugin v3.0.1 site, using PostgreSQL driver, the tables of the selected plugin are not listed. I can see the controllers, models, etc..
In a OctoberCMS v2 with the latest version of the Builder Plugin fro the OC version it works perfectly.

Database configuration:

  • OctoberCMS v4 is in its own schema - "october" (DB_SCHEMA points to it in .env);
  • There is a specific user with permissions to the "october" schema - "ocuser";

Problem

  • The result when calling the method \RainLab\Builder\Models\DatabaseTableModel::listPluginTables('acme.example") is an empty array because the "search_path/schema" is prepended to the table name.

Some investigation

  • In method "listPluginTables" the call: self::getSchemaManager()->listTableNames() return the list of tables but prefixed with the "search_path/schema", for example: " october. backend_users"
    • My first solution was to add the "search_path" to the $foundTables startsWith filter. (Yes, the tables were now listed in the UI but the migrations table were also prefixed with the "search_path" which failed)

Digging deeper

  • The "getSchemaSearchPaths" of the Class "Doctrine\DBAL\Schema\PostgreSqlSchemaManager" lists returns ['ocuser', 'public'] instead of ['october', 'public'].
    • Don't know why it returns the DB_USER instead of the DB_SCHEMA.
    • Since the result array is filtered by getCurrentSchema() ('october') and it does not exists, the resulting table name is the concatenation of the schema and the table name.

Hope that I didn't over explainded the situation :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions