migrations icon indicating copy to clipboard operation
migrations copied to clipboard

postgres schema is redirected when only a pdo connection is given in config

Open kimberv opened this issue 5 years ago • 1 comments

This is a (multiple allowed):

  • [x] bug

Using latest phinx 0.11.4

  • CakePHP Version: 3.8.9
  • Database server Postgres: 12.1
  • PHP Version: 7.4
  • Platform / OS: docker bref php

What you did

(This is pulled from an issue card created on phinx, I was directed to post the issue here.)

I use postgres with multiple schemas in one database, and I hand in my pdo connection via phinx config.connection rather than specify dsn settings.

Expected Behavior

I expect phinx/cake/whoever to trust the pdo connection I hand in, without messing with it.

Actual Behavior

On line 63 of CakeAdapter, code is resetting schema to public if config.schema is not given. The easy workaround is to specify schema in the config, but it seems unnecessary. Preferred would be that, if I hand phinx a pdo connection via config, it would trust it and leave it alone. An uneducated suggestion would be to change line 63 to something like:

     if (!isset($config['connection']) && $connection->getDriver() instanceof Postgres) {

kimberv avatar Feb 18 '20 13:02 kimberv

PR welcome.

dereuromark avatar Apr 11 '20 13:04 dereuromark