Skip to content

Commit

Permalink
Fix using schema option with connection option (#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin authored Oct 3, 2024
1 parent 0ef61fc commit 31d837c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Phinx/Db/Adapter/PostgresAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class PostgresAdapter extends PdoAdapter
*/
public function setOptions(array $options): AdapterInterface
{
parent::setOptions($options);

if (!empty($options['schema'])) {
$this->schema = $options['schema'];
}

parent::setOptions($options);

return $this;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/Phinx/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ public function testConnectionWithSchema()
$this->assertTrue($adapter->hasTable('foo.' . $adapter->getSchemaTableName()));
}

public function testConnectionWithSchemaAndConnection()
{
$this->adapter->connect();
$this->adapter->createSchema('foo');

$options = [
'schema' => 'foo',
'connection' => $this->adapter->getConnection(),
'name' => PGSQL_DB_CONFIG['name'],
];
$adapter = new PostgresAdapter($options, new ArrayInput([]), new NullOutput());
$adapter->connect();
$this->assertTrue($adapter->hasTable('foo.' . $adapter->getSchemaTableName()));
}

public function testCreatingTheSchemaTableOnConnect()
{
$this->adapter->connect();
Expand Down

0 comments on commit 31d837c

Please sign in to comment.