Skip to content

Add PostgreSQL auto-install and auto-upgrade support#106

Open
guillaume86 wants to merge 2 commits into
Dolibarr:mainfrom
guillaume86:feat/pgsql-auto-install
Open

Add PostgreSQL auto-install and auto-upgrade support#106
guillaume86 wants to merge 2 commits into
Dolibarr:mainfrom
guillaume86:feat/pgsql-auto-install

Conversation

@guillaume86

Copy link
Copy Markdown

Summary

  • Enable DOLI_INSTALL_AUTO=1 for PostgreSQL by removing the pgsql exclusion in docker-run.sh
  • Add pgsql branches for all MySQL-specific operations: DB wait, existence check, version query, initialization, migration (backup/restore), and custom script execution
  • PostgreSQL initialization reuses the existing PHP install scripts (step2.php / step5.php) which handle MySQL-to-PostgreSQL SQL conversion transparently via the pgsql driver's convertSQLFromMysql() method
  • Update examples/with-pgsql/docker-compose.yml with POSTGRES_DB and DOLI_URL_ROOT
  • Update README with auto-install and manual install sections for PostgreSQL, and document known limitations

PostgreSQL limitations

  • DOLI_INIT_DEMO=1 is not supported with PostgreSQL (demo dump is MySQL format). A warning is logged and the setting is skipped.
  • Custom .sql files in docker-init.d/ or before-starting.d/ must be written in PostgreSQL-compatible SQL (no automatic conversion).

Test plan

  • Build local image and run with docker compose (PostgreSQL 15 & 16)
  • Verify fresh install: 272 tables created, admin user exists, MAIN_VERSION_LAST_INSTALL set, install.lock created
  • Verify web UI accessible (HTTP 200, login page renders)
  • Verify container restart skips re-initialization (detects install.lock + existing DB)
  • Verify MySQL regression: existing MySQL compose works unchanged (399 tables, HTTP 200)
  • Verify upgrade path: version mismatch detected (22.0.4 → 23.0.0), pg_dump backup created, PHP upgrade scripts executed, DB correctly restored on failure

Note on upgrade test: The PHP migration scripts encountered SQL syntax errors from the upstream 22.0.0-23.0.0.sql migration file — this is a known upstream issue (Dolibarr/dolibarr#37425), not related to this PR. Our entrypoint code correctly detected the failure and restored the database from the pg_dump backup.

🤖 Generated with Claude Code

guillaume86 and others added 2 commits March 22, 2026 13:39
Enable DOLI_INSTALL_AUTO=1 for PostgreSQL by removing the pgsql exclusion
in docker-run.sh and adding pgsql branches for all MySQL-specific operations
(DB wait, existence check, version query, init, migration, backup/restore,
custom scripts). PostgreSQL initialization reuses the existing PHP install
scripts (step2.php/step5.php) which handle MySQL-to-PostgreSQL SQL conversion
transparently via the pgsql driver.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@guillaume86

Copy link
Copy Markdown
Author

For your information I didn't vibe code this, I actively guided claude across steps and tried to enforce good practices ;).

@YoussefWaelMohamedLotfy

Copy link
Copy Markdown

This needs to be merged ASAP, as I am seeking to use that. Kudos for the efforts @guillaume86

@creekorful creekorful self-assigned this Apr 20, 2026
@creekorful creekorful self-requested a review April 20, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants