Files
spencermandClaude Fable 5.1 591fe90076
ci / frontend (push) Successful in 30s
ci / server (push) Successful in 4m12s
ci / image (push) Successful in 46s
ci / e2e (push) Successful in 1m24s
Phase 3: VISUAL feed and M-Files drawings in the worker
Migration 0004 (VISUAL and drawing caches, go-live ignored list, resource
map, job tables, order-derived columns with provenance; work order key
includes the operation sequence). The real worker on APScheduler with
settings re-read each fire, pause, run now, advisory locks, job_runs and a
heartbeat. The visual-feed job (five VisualKit reads, COPY and MERGE cache,
suspect-batch guard, the apply in one transaction: drafts, change orders,
retire-moved, work order gone, closed and cancelled observed, projects and
units from order links, auto-release) and the fingerprint. The drawing-lookup
job (queue, budget, download on version change, sha256 into assets, decision
table, staging for rev approval, drawing-origin change orders). Clerical From
VISUAL panel, flags, rev approval, hand uploads, change-order review; Admin
Feed settings and resource map. Synthetic fixture generator and a
fixture-driven worker in CI with a Playwright scenario. Docs updated.

Verified: 3249 server tests and 13 Playwright scenarios on the docker-1 CI
stack, 76 frontend tests, doctor at 0004; one feed and one drawing run
against VISUAL DEV and the vault from the developer machine (counts in the
changelog).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-16 14:45:38 -06:00

55 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Runs once, when the postgres container starts on an empty pgdata volume.
# Creates the two login roles and the packetstation database.
# ps_migrate owns the database and its schema. Migrations run as this role.
# ps_app may connect. Table grants come from the migrations (0001).
# Passwords are read from the compose secret files, never from the environment or argv.
# The official image may source this file instead of executing it, so the body runs in a
# subshell and leaves the image's own shell options alone.
ps_create_roles() (
set -euo pipefail
for name in postgres_migrate_password postgres_app_password; do
f="/run/secrets/$name"
if [[ ! -r "$f" ]]; then
echo "01-roles: secret $name is missing or unreadable" >&2
exit 1
fi
if [[ ! -s "$f" ]]; then
echo "01-roles: secret $name is empty" >&2
exit 1
fi
if [[ "$(wc -l < "$f")" -gt 1 ]] || grep -q $'\r' "$f"; then
echo "01-roles: secret $name must be one line with no carriage return" >&2
exit 1
fi
done
# psql reads the passwords itself through backtick \set, so they never appear on a
# command line. :'name' quotes each value as a SQL literal.
psql -v ON_ERROR_STOP=1 --no-psqlrc --username "${POSTGRES_USER:-postgres}" --dbname postgres <<'SQL'
\set migrate_pw `cat /run/secrets/postgres_migrate_password`
\set app_pw `cat /run/secrets/postgres_app_password`
CREATE ROLE ps_migrate LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION PASSWORD :'migrate_pw';
CREATE ROLE ps_app LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION PASSWORD :'app_pw';
\unset migrate_pw
\unset app_pw
CREATE DATABASE packetstation OWNER ps_migrate ENCODING 'UTF8' TEMPLATE template0;
REVOKE ALL ON DATABASE packetstation FROM PUBLIC;
GRANT CONNECT, TEMPORARY ON DATABASE packetstation TO ps_app; -- TEMP: the feed COPYs into temp tables
\connect packetstation
-- PostgreSQL 15+ already denies CREATE on public to PUBLIC. Make it explicit and give
-- the schema to the migrate role.
REVOKE ALL ON SCHEMA public FROM PUBLIC;
ALTER SCHEMA public OWNER TO ps_migrate;
SQL
echo "01-roles: created ps_migrate, ps_app and database packetstation"
)
ps_create_roles