Skip to content

Commit

Permalink
Merge pull request #21 from MacPaw/develop
Browse files Browse the repository at this point in the history
Release PR
  • Loading branch information
alekseytupichenkov authored Apr 11, 2023
2 parents 94fd19e + fdd1add commit b37364b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
8 changes: 0 additions & 8 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ parameters:
message: '#.*NodeParentInterface|null.*#'
count: 1
path: ./src/DependencyInjection
-
message: '#Parameter \#2 ...\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given.#'
count: 1
path: ./src/Database/Manager/PostgreSQLDatabaseManager.php
-
message: '#Offset (.*)? does not exist on array\{(.*)?\}.#'
count: 9
path: ./src/Database/Manager/PostgreSQLDatabaseManager.php
-
message: '#Offset (.*)? does not exist on array\{(.*)?\}.#'
count: 1
Expand Down
35 changes: 23 additions & 12 deletions src/Database/Manager/PostgreSQLDatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public function saveBackup(array $fixtures): void
}

$databaseName = $this->getDatabaseName();
$password = $this->connection->getParams()['password'];
$user = $this->connection->getParams()['user'];
$host = $this->connection->getParams()['host'];
$port = $this->connection->getParams()['port'];
$password = $this->getConnectionParams()['password'];
$user = $this->getConnectionParams()['user'];
$host = $this->getConnectionParams()['host'];
$port = $this->getConnectionParams()['port'];

# Needed for optimization
$additionalParams = sprintf('--no-comments --disable-triggers --data-only -T %s', $this->migrationsTable);
Expand Down Expand Up @@ -82,10 +82,10 @@ public function loadBackup(array $fixtures): void

$backupFilename = $this->getBackupFilename($fixtures);
$databaseName = $this->getDatabaseName();
$password = $this->connection->getParams()['password'];
$user = $this->connection->getParams()['user'];
$host = $this->connection->getParams()['host'];
$port = $this->connection->getParams()['port'];
$password = $this->getConnectionParams()['password'];
$user = $this->getConnectionParams()['user'];
$host = $this->getConnectionParams()['host'];
$port = $this->getConnectionParams()['port'];

$this->consoleManager->loadDump($backupFilename, $user, $host, $port, $databaseName, $password);

Expand Down Expand Up @@ -132,10 +132,13 @@ private function restartSequences(): void
$sequences = $this->connection->executeQuery('SELECT * FROM information_schema.sequences')
->fetchAllAssociative();

/** @var array{sequence_name: string, start_value?: string} $sequence */
foreach ($sequences as $sequence) {
$this->connection->executeStatement(
sprintf('ALTER SEQUENCE %s RESTART WITH 1', $sequence['sequence_name'])
);
$this->connection->executeStatement(sprintf(
'ALTER SEQUENCE %s RESTART WITH %s',
$sequence['sequence_name'],
$sequence['start_value'] ?? '1'
));
}
}

Expand Down Expand Up @@ -172,6 +175,14 @@ private function runMigrations(): void

protected function getDatabaseName(): string
{
return $this->connection->getParams()['dbname'];
return $this->getConnectionParams()['dbname'];
}

private function getConnectionParams(): array
{
/** @var array{dbname: string, password: string, user: string, host: string, port: int} $connectionParams */
$connectionParams = $this->connection->getParams();

return $connectionParams;
}
}

0 comments on commit b37364b

Please sign in to comment.