Skip to content

Commit

Permalink
chore: prevent error when no upstream connection available
Browse files Browse the repository at this point in the history
Signed-off-by: Fery Wardiyanto <[email protected]>
  • Loading branch information
feryardiant committed Jan 9, 2025
1 parent 6ca02e3 commit 05e0295
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ jobs:

- name: Stat databases
run: |
./vendor/bin/testbench nusa:stat
git status
./vendor/bin/testbench nusa:stat --diff
./vendor/bin/testbench nusa:stat > /dev/null
git diff resources/**/*.csv
- name: Upload tests reports
uses: actions/upload-artifact@v4
Expand Down
25 changes: 15 additions & 10 deletions workbench/app/Console/DatabaseImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@ public function __construct()
parent::__construct();

$this->libPath = \realpath(\dirname(__DIR__).'/../..');
$conn = DB::connection('upstream');

$this->conn = new PDO(
"mysql:dbname={$conn->getConfig('database')};host={$conn->getConfig('host')}",
$conn->getConfig('username'),
$conn->getConfig('password'),
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]
);

try {
$conn = DB::connection('upstream');

$this->conn = new PDO(
"mysql:dbname={$conn->getConfig('database')};host={$conn->getConfig('host')}",
$conn->getConfig('username'),
$conn->getConfig('password'),
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]
);
} catch (\PDOException $_) {
//
}
}

public function handle()
Expand Down

0 comments on commit 05e0295

Please sign in to comment.