Skip to content

Commit

Permalink
Add interface
Browse files Browse the repository at this point in the history
  • Loading branch information
fezfez committed Jan 8, 2023
1 parent 4855ee8 commit 9f4a8f8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Databases/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ public function getDumpStructCommandLine(string $path): string;
public function getDumpDataCommandLine(string $path): string;

public function getRestoreCommandLine(string $path): string;

/** @param array<int, string> $onlyTables */
public function withOnlyTable(array $onlyTables): self;

/** @param array<int, string> $ignoreTables */
public function withIgnoreTable(array $ignoreTables): self;
}
34 changes: 34 additions & 0 deletions src/Databases/PostgresqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,49 @@

final class PostgresqlDatabase implements Database
{
/**
* @param array<int, string> $ignoreTables
* @param array<int, string> $onlyTables
*/
public function __construct(
private readonly string $host,
private readonly string $port,
private readonly string $user,
private readonly string $password,
private readonly string $database,
private readonly array $ignoreTables = [],
private readonly array $onlyTables = [],
) {
}

/** @param array<int, string> $onlyTables */
public function withOnlyTable(array $onlyTables): self
{
return new self(
$this->host,
$this->port,
$this->user,
$this->password,
$this->database,
$this->ignoreTables,
$onlyTables,
);
}

/** @param array<int, string> $ignoreTables */
public function withIgnoreTable(array $ignoreTables): self
{
return new self(
$this->host,
$this->port,
$this->user,
$this->password,
$this->database,
$ignoreTables,
$this->onlyTables,
);
}

public function getDumpDataCommandLine(string $path): string
{
return sprintf(
Expand Down

0 comments on commit 9f4a8f8

Please sign in to comment.