Skip to content

Issue Report: Native PostgreSQL Support Failures (Docker) #7920

@stephanemar

Description

@stephanemar

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • I agree to follow Monica's Code of Conduct.

Bug description

Native PostgreSQL Support Failures (Docker)

Steps to reproduce

Environment:

Image: monica:latest
Database: PostgreSQL 15+ (Native, not via MySQL/MariaDB container)
Driver: pdo_pgsql (Extensions verified present in container)

  1. Entrypoint Compatibility Check
    The stock /usr/local/bin/entrypoint.sh includes a

waitfordb
function that forces a MySQL connection check using mysqli.

Issue: This check fails hard when DB_CONNECTION=pgsql is set, preventing the container from starting even if the Postgres database is ready.

Workaround Applied: We replaced

entrypoint.sh
with a custom script that skips the

waitfordb
check or uses a generic TCP check.

Recommendation: The entrypoint should check the DB_CONNECTION variable and either:

Skip the check if not mysql.
Use a driver-agnostic check (e.g., php artisan db:monitor or a simple TCP socket check).
2. Migration Syntax Error (PostgreSQL Incompatibility)
File: database/migrations/2017_06_07_173437_add_multiple_genders_choices.php

Issue: The

alterEnum
method manually constructs SQL statements using backticks (`) to escape table and constraint names:

$check = "${table}_${field}_check"; // Result: contacts_gender_check
// and
DB::statement(sprintf('ALTER TABLE %s DROP CONSTRAINT %s;', $table, $check));
Backticks are MySQL-specific. On PostgreSQL, this throws a syntax error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ""`

Workaround Applied: We patched the file to strip backticks from the $table variable before constructing the constraint name:

$table = str_replace('`', '', $table);
Recommendation: The migration should use the query builder or properly quote identifiers based on the active driver, rather than hardcoding backticks.

Expected behavior

Issue Report: Native PostgreSQL Support Failures (Docker)
Environment:

Image: monica:latest
Database: PostgreSQL 15+ (Native, not via MySQL/MariaDB container)
Driver: pdo_pgsql (Extensions verified present in container)

  1. Entrypoint Compatibility Check
    The stock /usr/local/bin/entrypoint.sh includes a

waitfordb
function that forces a MySQL connection check using mysqli.

Issue: This check fails hard when DB_CONNECTION=pgsql is set, preventing the container from starting even if the Postgres database is ready.

Workaround Applied: We replaced

entrypoint.sh
with a custom script that skips the

waitfordb
check or uses a generic TCP check.

Recommendation: The entrypoint should check the DB_CONNECTION variable and either:

Skip the check if not mysql.
Use a driver-agnostic check (e.g., php artisan db:monitor or a simple TCP socket check).
2. Migration Syntax Error (PostgreSQL Incompatibility)
File: database/migrations/2017_06_07_173437_add_multiple_genders_choices.php

Issue: The

alterEnum
method manually constructs SQL statements using backticks (`) to escape table and constraint names:

$check = "${table}_${field}_check"; // Result: contacts_gender_check
// and
DB::statement(sprintf('ALTER TABLE %s DROP CONSTRAINT %s;', $table, $check));
Backticks are MySQL-specific. On PostgreSQL, this throws a syntax error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ""`

Workaround Applied: We patched the file to strip backticks from the $table variable before constructing the constraint name:

$table = str_replace('`', '', $table);
Recommendation: The migration should use the query builder or properly quote identifiers based on the active driver, rather than hardcoding backticks.

Environment

app.monicahq.com (monica v4)

Version of Monica

No response

Installation method

None

Web server

None

Database engine version

None

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions