Skip to content

Add missing database driver in CLI#2317

Merged
notAreYouScared merged 1 commit into
pelican-dev:mainfrom
karaolidis:missing-cli-driver
May 5, 2026
Merged

Add missing database driver in CLI#2317
notAreYouScared merged 1 commit into
pelican-dev:mainfrom
karaolidis:missing-cli-driver

Conversation

@karaolidis
Copy link
Copy Markdown
Contributor

Unless there was an explicit reason this was missing, I think this is a bug?

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

Adds PostgreSQL as a selectable database driver in the interactive database settings command and implements prompts, connection-configuration, and connectivity testing for PostgreSQL during the command's execution.

Changes

Database Settings: PostgreSQL support

Layer / File(s) Summary
Driver Options
app/Console/Commands/Environment/DatabaseSettingsCommand.php
DATABASE_DRIVERS constant gains 'pgsql' => 'PostgreSQL'.
Command Signature / Help
app/Console/Commands/Environment/DatabaseSettingsCommand.php
$signature updated so --host, --port, --username, and --password help text mention PostgreSQL in addition to MySQL/MariaDB.
Interactive Prompts
app/Console/Commands/Environment/DatabaseSettingsCommand.php
handle() now includes an elseif branch for DB_CONNECTION === 'pgsql' to prompt for host, port, database, username, and password (with optional reuse of existing password).
Connection Configuration
app/Console/Commands/Environment/DatabaseSettingsCommand.php
Sets database.connections._panel_command_test with driver => 'pgsql' and Postgres-specific options (host, port, database, username, password, charset, search_path, sslmode).
Connectivity Test & Flow Control
app/Console/Commands/Environment/DatabaseSettingsCommand.php
Attempts getPdo() on the test connection; on failure prints error, disconnects, and optionally allows going back (recursive rerun), otherwise returns exit code 1 for failure.
sequenceDiagram
    participant CLI as Console Command
    participant Config as Laravel DB Config
    participant PG as PostgreSQL Server

    CLI->>CLI: Prompt user for pgsql host/port/db/user/password
    CLI->>Config: Set database.connections._panel_command_test (driver: pgsql, params...)
    CLI->>PG: Attempt getPdo() (connect)
    alt Connection success
        PG-->>CLI: Connection established
        CLI-->>Config: Proceed / persist settings
    else Connection failure
        PG-->>CLI: Error/exception
        CLI-->>CLI: Print error, disconnect, offer "go back"
        alt User chooses retry
            CLI->>CLI: Re-run prompts/flow
        else
            CLI-->>Caller: Exit with code 1
        end
    end
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add missing database driver in CLI' clearly summarizes the main change: adding PostgreSQL database driver support to the CLI command.
Description check ✅ Passed The description relates to the changeset by noting the addition appears to fix a missing database driver, though it provides minimal implementation detail.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Console/Commands/Environment/DatabaseSettingsCommand.php`:
- Line 19: DATABASE_DRIVERS includes 'pgsql' but handle() lacks a pgsql branch
so selecting PostgreSQL skips prompts and connection testing; add an elseif
($this->variables['DB_CONNECTION'] === 'pgsql') block inside the handle() method
(same place as the mysql/mariadb/sqlite branches) that mirrors their interactive
flow: use config('database.connections.pgsql.host'),
config('database.connections.pgsql.port'),
config('database.connections.pgsql.database'),
config('database.connections.pgsql.username') and
config('database.connections.pgsql.password') as defaults, prompt the user for
host/port/database/username/password, write those into $this->variables (same
keys used by other branches), and invoke the same connection test routine used
by the other branches to validate the credentials before saving.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 272e284a-5253-4925-a28c-0b15f11db742

📥 Commits

Reviewing files that changed from the base of the PR and between 4464ccb and 061fb11.

📒 Files selected for processing (1)
  • app/Console/Commands/Environment/DatabaseSettingsCommand.php

Comment thread app/Console/Commands/Environment/DatabaseSettingsCommand.php
@karaolidis karaolidis marked this pull request as draft May 5, 2026 15:30
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
@karaolidis karaolidis force-pushed the missing-cli-driver branch from 061fb11 to 4c2ca36 Compare May 5, 2026 15:32
@karaolidis karaolidis marked this pull request as ready for review May 5, 2026 15:33
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/Console/Commands/Environment/DatabaseSettingsCommand.php (1)

62-244: 🏗️ Heavy lift

Consider consolidating MySQL/MariaDB/PostgreSQL setup into a shared helper.

The three branches now have near-identical prompt/test logic. Centralizing this with a per-driver config map would reduce future drift (like missing one driver in later updates).

Refactor direction (sketch)
+// 1) Define per-driver metadata/default config paths in one map.
+// 2) Reuse one method to:
+//    - ask host/port/database/username/password
+//    - build _panel_command_test connection config
+//    - run getPdo() + shared error/retry handling
+
- if ($this->variables['DB_CONNECTION'] === 'mysql') { ... }
- elseif ($this->variables['DB_CONNECTION'] === 'mariadb') { ... }
- elseif ($this->variables['DB_CONNECTION'] === 'pgsql') { ... }
+ if (in_array($this->variables['DB_CONNECTION'], ['mysql', 'mariadb', 'pgsql'], true)) {
+     return $this->handleSqlDriver($this->variables['DB_CONNECTION']);
+ }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Console/Commands/Environment/DatabaseSettingsCommand.php` around lines 62
- 244, The three DB branches in DatabaseSettingsCommand handling
mysql/mariadb/pgsql duplicate prompting and connection-testing logic; extract
that into a shared helper (e.g., a private method gatherAndTestSqlConnection or
testSqlDriverConnection) that accepts the driver identifier and a per-driver
config map (driver name, default port, default database, default username,
config keys like database.connections.{driver}) to perform
host/port/database/username/password prompts, set the temporary
'_panel_command_test' config, call
$this->database->connection('_panel_command_test')->getPdo(), and handle the
PDOException (including $this->database->disconnect('_panel_command_test') and
the existing confirm/return behavior); then replace the mysql/mariadb/pgsql
branches in handle() to call that helper with the appropriate map to remove the
duplicated code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/Console/Commands/Environment/DatabaseSettingsCommand.php`:
- Around line 62-244: The three DB branches in DatabaseSettingsCommand handling
mysql/mariadb/pgsql duplicate prompting and connection-testing logic; extract
that into a shared helper (e.g., a private method gatherAndTestSqlConnection or
testSqlDriverConnection) that accepts the driver identifier and a per-driver
config map (driver name, default port, default database, default username,
config keys like database.connections.{driver}) to perform
host/port/database/username/password prompts, set the temporary
'_panel_command_test' config, call
$this->database->connection('_panel_command_test')->getPdo(), and handle the
PDOException (including $this->database->disconnect('_panel_command_test') and
the existing confirm/return behavior); then replace the mysql/mariadb/pgsql
branches in handle() to call that helper with the appropriate map to remove the
duplicated code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d99926e0-db59-4c9d-8353-4f9ebb62626f

📥 Commits

Reviewing files that changed from the base of the PR and between 061fb11 and 4c2ca36.

📒 Files selected for processing (1)
  • app/Console/Commands/Environment/DatabaseSettingsCommand.php

@notAreYouScared notAreYouScared merged commit d520224 into pelican-dev:main May 5, 2026
17 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
@karaolidis karaolidis deleted the missing-cli-driver branch May 5, 2026 16:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants