From daf29f22dce75395e5001d64b065268eb569a308 Mon Sep 17 00:00:00 2001 From: Ilia Pasechnikov Date: Thu, 9 Jul 2026 01:22:37 +0900 Subject: [PATCH] =?UTF-8?q?chore(compose):=20drop=20redundant=20init-datab?= =?UTF-8?q?ases.sql=20=E2=80=94=20apps=20self-create=20their=20dbs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both apps create their own database on first boot: Aidbox always, and the engine since 1.4.0 (the ensure-database step). Pre-creating interbox + aidbox via an initdb SQL is therefore redundant on current versions (.env.example ships 1.4.2). Verified empirically: with the init SQL gone and a fresh volume, `docker compose up` on 1.4.2 creates both `interbox` and `aidbox` databases and boots — engine logs "ensuring database exists…" then "migrations applied"; Aidbox creates its own db after an initial retry. Note: requires engine >= 1.4.0 (older images have no self-create step and would need the db pre-created). Co-Authored-By: Claude Opus 4.8 (1M context) --- compose/init-databases.sql | 10 ---------- docker-compose.yaml | 6 ++---- 2 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 compose/init-databases.sql diff --git a/compose/init-databases.sql b/compose/init-databases.sql deleted file mode 100644 index 4dce4d6..0000000 --- a/compose/init-databases.sql +++ /dev/null @@ -1,10 +0,0 @@ --- First-boot bootstrap for the shared Postgres cluster. --- --- The official postgres image auto-creates exactly one database (POSTGRES_DB). --- Interbox and Aidbox are peers, each owning its own database in the one cluster, --- so we create both explicitly here. Neither app issues CREATE DATABASE itself — --- they connect to an existing database and build their schema inside it. --- --- initdb runs this once, only when the data directory is empty (fresh volume). -CREATE DATABASE interbox; -CREATE DATABASE aidbox; diff --git a/docker-compose.yaml b/docker-compose.yaml index ce5d1b8..aeacb64 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,7 +25,8 @@ services: pg: # Single Postgres 18 cluster shared by Interbox and Aidbox — each owns its own - # database (interbox, aidbox), created first-boot by compose/init-databases.sql. + # database (interbox, aidbox). Both apps create their own database on first boot + # (Aidbox always; the engine since 1.4.0), so no init SQL is needed. # Interbox needs only pg_trgm + btree_gist (bundled contrib); Aidbox wants # pg_stat_statements, preloaded below. image: postgres:18 @@ -43,9 +44,6 @@ services: - "5432:5432" volumes: - pg-data:/var/lib/postgresql/18/docker - # First-boot only: creates the interbox + aidbox databases. The postgres image - # auto-creates only one db (POSTGRES_DB); with two peers we create both here. - - ./compose/init-databases.sql:/docker-entrypoint-initdb.d/10-databases.sql:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] interval: 2s