`debug_kit` datasource ignoring the configured `schema` when setting up initial `requests` and `panels` tables
I want to use DebugKit in the same database as the main CakePHP application, but in a different schema, so I've configured DebugKit with the following datasource:
[
'className' => Connection::class,
'driver' => Postgres::class,
'timezone' => 'Australia/Brisbane',
'host' => 'host.docker.internal',
'port' => 5414,
'username' => 'learn_cakephp_4_user',
'password' => '<<password>>',
'database' => 'learn_cakephp_4',
'schema' => 'debug_kit',
'log' => true
]
However, when attempting to create the initial requests and panels tables, they do not get created, and I'm met with these errors on the web page:
[Warning (512)](javascript:void(0);): Fixture creation for "requests" failed "SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in at character 14" [CORE/src/TestSuite/Fixture/TestFixture.php, line 296]
[Warning (512)](javascript:void(0);): Fixture creation for "panels" failed "SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in at character 14" [CORE/src/TestSuite/Fixture/TestFixture.php, line 296]
[Warning (512)](javascript:void(0);): Unable to emit headers. Headers sent in file=/src/vendor/cakephp/cakephp/src/Error/Debugger.php line=988 [CORE/src/Http/ResponseEmitter.php, line 71]
[Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /src/vendor/cakephp/cakephp/src/Error/Debugger.php:988) [CORE/src/Http/ResponseEmitter.php, line 168]
[Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at /src/vendor/cakephp/cakephp/src/Error/Debugger.php:988) [CORE/src/Http/ResponseEmitter.php, line 197]
Looking at the query logs, the CREATE statements are missing the schema prefix on the table name, but the schema is being specified in the SELECTs before and after:
2022-03-31 07:48:28 debug: connection=debug_kit duration=23 rows=0 SELECT table_name as name FROM information_schema.tables
WHERE table_schema = 'debug_kit' ORDER BY name
2022-03-31 07:48:29 debug: connection=debug_kit duration=0 rows=0 CREATE TABLE "requests" (
"id" UUID NOT NULL,
"url" TEXT NOT NULL,
"content_type" VARCHAR,
"status_code" INTEGER,
"method" VARCHAR,
"requested_at" TIMESTAMP NOT NULL,
PRIMARY KEY ("id")
)
2022-03-31 07:48:29 debug: connection=debug_kit duration=0 rows=0 CREATE TABLE "panels" (
"id" UUID,
"request_id" UUID NOT NULL,
"panel" VARCHAR,
"title" VARCHAR,
"element" VARCHAR,
"summary" VARCHAR,
"content" BYTEA,
PRIMARY KEY ("id"),
CONSTRAINT "unique_panel" UNIQUE ("request_id", "panel")
)
2022-03-31 07:48:29 debug: connection=debug_kit duration=13 rows=0 SELECT DISTINCT table_schema AS schema,
column_name AS name,
data_type AS type,
is_nullable AS null, column_default AS default,
character_maximum_length AS char_length,
c.collation_name,
d.description as comment,
ordinal_position,
c.datetime_precision,
c.numeric_precision as column_precision,
c.numeric_scale as column_scale,
pg_get_serial_sequence(attr.attrelid::regclass::text, attr.attname) IS NOT NULL AS has_serial
FROM information_schema.columns c
INNER JOIN pg_catalog.pg_namespace ns ON (ns.nspname = table_schema)
INNER JOIN pg_catalog.pg_class cl ON (cl.relnamespace = ns.oid AND cl.relname = table_name)
LEFT JOIN pg_catalog.pg_index i ON (i.indrelid = cl.oid AND i.indkey[0] = c.ordinal_position)
LEFT JOIN pg_catalog.pg_description d on (cl.oid = d.objoid AND d.objsubid = c.ordinal_position)
LEFT JOIN pg_catalog.pg_attribute attr ON (cl.oid = attr.attrelid AND column_name = attr.attname)
WHERE table_name = 'requests' AND table_schema = 'debug_kit' AND table_catalog = 'learn_cakephp_4'
ORDER BY ordinal_position
PHP version is 8.1, CakePHP version is 4.3.7, and DebugKit version is 4.7.1.
I tried creating the tables under the intended schema manually, using the logged queries, but DebugKit still tries to create them from scratch, even though the SELECT queries now return data. Only using an entirely different database seems to make things work.