Skip to content

Commit 8e9997a

Browse files
committed
[FIX] PostgreSQL support.
1 parent cefe2cf commit 8e9997a

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

internal/engine/install/engine.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,9 @@ func runPHPNewCommand(ctx context.Context, emit func(domain.Event) bool, opt php
11511151
lastWasSeederStart := false
11521152
lastSeeder := ""
11531153
lastStep := ""
1154+
lastPlainLine := ""
1155+
lastPlainStepID := ""
1156+
lastPlainWasStderr := false
11541157

11551158
for l := range linesCh {
11561159
line := l.text
@@ -1219,13 +1222,23 @@ func runPHPNewCommand(ctx context.Context, emit func(domain.Event) bool, opt php
12191222
sev = domain.SeverityWarn
12201223
}
12211224

1225+
fields := map[string]string(nil)
1226+
if line == lastPlainLine && stepID == lastPlainStepID && l.stderr == lastPlainWasStderr {
1227+
fields = map[string]string{"op": "replace_last"}
1228+
} else {
1229+
lastPlainLine = line
1230+
lastPlainStepID = stepID
1231+
lastPlainWasStderr = l.stderr
1232+
}
1233+
12221234
_ = emit(domain.Event{
12231235
Type: evType,
12241236
StepID: stepID,
12251237
Source: "php",
12261238
Severity: sev,
12271239
Payload: domain.LogPayload{
12281240
Message: line,
1241+
Fields: fields,
12291242
},
12301243
})
12311244
}

src/Commands/InstallCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class InstallCommand extends Command
2525

2626
protected ?OutputInterface $logSection = null;
2727
protected ?TuiRenderer $tui = null;
28+
protected ?string $lastDatabaseConnectionError = null;
2829
protected array $composerCommandCache = [];
2930
protected array $steps = [
3031
'php' => ['label' => 'Step 1: Validate PHP version', 'completed' => false],
@@ -220,6 +221,13 @@ protected function gatherInputs(InputInterface $input, OutputInterface $output):
220221
if ($this->testDatabaseConnection($inputs['database'])) {
221222
$databaseConnected = true;
222223
} else {
224+
if (!$input->isInteractive()) {
225+
$msg = is_string($this->lastDatabaseConnectionError) ? trim($this->lastDatabaseConnectionError) : '';
226+
if ($msg === '') {
227+
$msg = 'Unknown database connection error.';
228+
}
229+
throw new \RuntimeException('Database connection failed: ' . $msg);
230+
}
223231
// Connection failed, ask user what to do
224232
if (!$this->askRetryDatabaseConnection()) {
225233
throw new \RuntimeException('Installation cancelled by user.');
@@ -436,6 +444,7 @@ protected function askDatabasePassword(): string
436444
*/
437445
protected function testDatabaseConnection(array $config): bool
438446
{
447+
$this->lastDatabaseConnectionError = null;
439448
$this->tui->addLog('Testing database connection...');
440449

441450
try {
@@ -464,13 +473,15 @@ protected function testDatabaseConnection(array $config): bool
464473
'Please install PHP extension: ' . ($type === 'sqlite' ? 'pdo_sqlite' : 'pdo_' . $type) . '.',
465474
2
466475
);
476+
$this->lastDatabaseConnectionError = 'PDO driver for ' . $driverName . ' is not available.';
467477
return false;
468478
}
469479

470480
if ($type === 'sqlite') {
471481
// SQLite: Connect directly to the database file
472482
if (empty($config['name'])) {
473483
$this->tui->replaceLastLogs('<fg=red>✗</> Database connection failed: SQLite database path is required.', 2);
484+
$this->lastDatabaseConnectionError = 'SQLite database path is required.';
474485
return false;
475486
}
476487
$this->createConnection($config);
@@ -536,6 +547,7 @@ protected function testDatabaseConnection(array $config): bool
536547
$errorMessage = "PDO driver for {$driverName} is not installed. Please install PHP extension: {$extensionName}";
537548
}
538549

550+
$this->lastDatabaseConnectionError = $errorMessage;
539551
$this->tui->replaceLastLogs('<fg=red>✗</> Database connection failed: ' . $errorMessage, 2);
540552
return false;
541553
}

0 commit comments

Comments
 (0)