on productiomn (mnew install)
migrate-1 | Created database 'sandcastle_production_cable'
migrate-1 | Admin user created: <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
postgres-1 | waiting for server to start....2026-02-12 15:47:18.400 UTC [51] LOG: starting PostgreSQL 18.1 (Debian 18.1-1.pgdg13+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
postgres-1 | 2026-02-12 15:47:18.403 UTC [51] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres-1 | 2026-02-12 15:47:18.415 UTC [57] LOG: database system was shut down at 2026-02-12 15:47:18 UTC
postgres-1 | 2026-02-12 15:47:18.421 UTC [51] LOG: database system is ready to accept connections
postgres-1 | done
postgres-1 | server started
postgres-1 | CREATE DATABASE
postgres-1 |
postgres-1 |
postgres-1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres-1 |
postgres-1 | 2026-02-12 15:47:18.598 UTC [51] LOG: received fast shutdown request
postgres-1 | waiting for server to shut down....2026-02-12 15:47:18.601 UTC [51] LOG: aborting any active transactions
postgres-1 | 2026-02-12 15:47:18.603 UTC [51] LOG: background worker "logical replication launcher" (PID 60) exited with exit code 1
postgres-1 | 2026-02-12 15:47:18.604 UTC [55] LOG: shutting down
postgres-1 | 2026-02-12 15:47:18.607 UTC [55] LOG: checkpoint starting: shutdown immediate
postgres-1 | 2026-02-12 15:47:18.687 UTC [55] LOG: checkpoint complete: wrote 943 buffers (5.8%), wrote 3 SLRU buffers; 0 WAL file(s) added, 0 removed, 0 recycled; write=0.036 s, sync=0.031 s, total=0.083 s; sync files=303, longest=0.004 s, average=0.001 s; distance=4352 kB, estimate=4352 kB; lsn=0/1B9FBB8, redo lsn=0/1B9FBB8
postgres-1 | 2026-02-12 15:47:18.709 UTC [51] LOG: database system is shut down
postgres-1 | done
postgres-1 | server stopped
postgres-1 |
postgres-1 | PostgreSQL init process complete; ready for start up.
postgres-1 |
postgres-1 | 2026-02-12 15:47:18.841 UTC [1] LOG: starting PostgreSQL 18.1 (Debian 18.1-1.pgdg13+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
postgres-1 | 2026-02-12 15:47:18.841 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres-1 | 2026-02-12 15:47:18.841 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres-1 | 2026-02-12 15:47:18.848 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres-1 | 2026-02-12 15:47:18.859 UTC [73] LOG: database system was shut down at 2026-02-12 15:47:18 UTC
postgres-1 | 2026-02-12 15:47:18.865 UTC [1] LOG: database system is ready to accept connections
postgres-1 | 2026-02-12 15:47:24.613 UTC [87] FATAL: database "sandcastle_production_cache" does not exist
postgres-1 | 2026-02-12 15:47:24.891 UTC [90] FATAL: database "sandcastle_production_queue" does not exist
postgres-1 | 2026-02-12 15:47:25.162 UTC [93] FATAL: database "sandcastle_production_cable" does not exist
Assistant
The issue is that the migrate step only created the primary + cable databases, but not the cache and queue databases. Let me check the database config and compose setup.
Assistant
Let me check the migration directories and the db seed/prepare setup.
Assistant
Found the issue. The database.yml production config uses 4 separate PostgreSQL databases (primary, cache, queue, cable), but PostgreSQL's POSTGRES_DB only creates sandcastle_production. db:prepare managed to create the cable db but missed cache and queue.
The fix is to add a PostgreSQL init script that creates all required databases on first startup. Let me also check if perhaps the schema files are set up correctly for Solid gems.
Assistant
The problem is clear: PostgreSQL only creates sandcastle_production via POSTGRES_DB, and db:prepare is unreliable at creating the other 3 databases. The fix is to add a PostgreSQL init script that creates all required databases on first startup.
Assistant
Now mount it in the PostgreSQL service:
Assistant
Let me also check if the local compose file needs the same fix:
Assistant
Same issue in the local compose. Let me fix it too:
Assistant
Let me verify the final state of both files:
Assistant
Here's what was wrong and what I fixed:
Problem: The database.yml production config uses 4 separate PostgreSQL databases (sandcastle_production, _cache, _queue, _cable), but PostgreSQL's POSTGRES_DB only creates the primary one. db:prepare was supposed to create the rest but only managed to create _cable, leaving _cache and _queue missing.
Fix: Added docker/postgres/init-databases.sh — a PostgreSQL init script that creates all 3 extra databases during the first PostgreSQL startup (before db:prepare even runs). Both docker-compose.yml and docker-compose.local.yml now mount it into /docker-entrypoint-initdb.d/.
To apply on production: Since the PostgreSQL volume already exists, the init script won't run automatically (it only runs on fresh init). You'll need to either:
Or nuke and restart (if it's a fresh install anyway):
bash
docker compose down -v
docker compose up -d
User
do in need to build new images?
Assistant
No. The init script runs inside the PostgreSQL container (stock postgres:18 image), not your Rails image. It's bind-mounted at runtime via the compose file.
You just need to:
Copy the updated docker-compose.yml and docker/postgres/init-databases.sh to the server
Since the PG volume already exists from your first run, create the missing databases manually:
The init script will handle it automatically on any future fresh installs.
User
i installed via cual installer.sh - is all included in the installer?
Assistant
Let me check what the installer does with compose files.
Assistant
No — the installer generates its own docker-compose.yml inline (line 721). It doesn't use the repo's compose file or the init script. I need to update the installer to include the database init script.
Assistant
Now mount the init script in the postgres service inside the generated compose file:
Assistant
Let me verify the relevant section looks right:
Assistant
Looks good. Now for your current broken install, the quickest fix is to run these two commands on the server:
bash
# Create the missing databases
/sandcastle/docker-runtime/bin/docker compose -f /sandcastle/docker-compose.yml --env-file /sandcastle/.env exec postgres \
psql -U sandcastle -d sandcastle_production \
-c "CREATE DATABASE sandcastle_production_cache OWNER sandcastle;" \
-c "CREATE DATABASE sandcastle_production_queue OWNER sandcastle;"
# Restart to pick up the new databases
/sandcastle/docker-runtime/bin/docker compose -f /sandcastle/docker-compose.yml --env-file /sandcastle/.env up -d
Or if you'd rather do a clean reset with the fixed installer, push this commit, then re-run sudo installer.sh reset on the server.
User
lead a not in CLAUDE.md about this!
Assistant
The Database section is outdated (still says SQLite). Let me update it:
Assistant
Also updating the Background Jobs section since it still says SQLite-backed:
Assistant
And updating the memory file to match:
Assistant
Done. Updated:
CLAUDE.md — Database section now documents the 4 PostgreSQL databases, the init script, and the rule to keep both in sync when adding/removing Solid databases
CLAUDE.md — Removed stale "SQLite-backed" from Background Jobs section
MEMORY.md — Updated tech stack from SQLite to PostgreSQL
User
commit and push
Assistant
Pushed. Now on the server you can either:
Quick fix — create the 2 missing databases manually (the command I gave earlier), then restart
Clean reinstall — sudo installer.sh reset which will now write the init script and create all databases automatically
User
thies@sandman:~$ sudo /sandcastle/docker-runtime/bin/docker compose logs -f
no configuration file provided: not found
Assistant
The compose command needs the file path and env file. Try:
That's pretty verbose though. You could add a shell alias or just cd /sandcastle first — compose auto-finds docker-compose.yml in the current directory. But it still needs --env-file .env.