Strategy: per-environment Postgres DBs, MariaDB→Postgres migration, and embedding service deploy #95
Replies: 1 comment
-
Wrinkle: a
|
Beta Was this translation helpful? Give feedback.
-
Wrinkle: a
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Now that the deploy workflow (#93, #94) is wiring staging and production deploys to per-major directories (
/dev,/v3,/v4, …) on the shared VPS, a few related decisions are converging that are worth pinning down in one place. Posting this for review and to track follow-up PRs.Open architectural questions
/dev,/v3,/v4each have their own Postgres database so schema migrations introduced in/v4don't affect/v3?developmentbranch has migrated to Postgres but production is still on MariaDB; how do we cut over with the lowest risk?services/embedding/is a long-running FastAPI service (uvicorn + a 470 MB sentence-transformers model). The chrooted SSH user that handles the PHP rsync deploy can't reach/opt, so it can't manage a system service. What's the right deploy lane?Proposal
1. DB-per-environment
Yes, give each major version its own database. It lines up perfectly with the per-major deploy paths the workflow already creates.
${VPS_APP_DIR}/devbibleget_dev${VPS_APP_DIR}/v3bibleget_v3${VPS_APP_DIR}/v4bibleget_v4Each deploy's
.env(server-managed, never overwritten by the workflow) points at its own DB.migrations/ships with the code, so a/vNdeploy carries the migration set valid for branch N — the runner only sees what was shipped, which is what we want. Major-version-breaking schema changes are safe because they only ever land against a freshly-provisionedbibleget_v(N+1).2. Migration runner
To make per-env DBs work in CI, we need:
schema_migrations(or equivalent) table trackingfilename,applied_at. Created on first run if absent.scripts/(Composer + PHP are already on the runner). Readsmigrations/*.sql, diffs against the table, applies pending in order, transactional where possible.ssh user@host "cd $DEPLOY_PATH && php scripts/migrate.php". Failures abort the deploy.IF NOT EXISTSeverywhere) for defensive re-runnability.3. MariaDB → Postgres playbook
Stage on the dev DB first, promote to v3 only once smoke tests pass:
Prerequisite: ensure
pgvectoris installed on the server's Postgres (one of the migrations adds the extension).4. Embedding service deploy lane
The chroot blocks
/optand bolting sudo onto the chrooted user defeats the chroot. Two clean shapes:bibleget-embed)~/embedding//opt/bibleget-embedding/systemctl --user) or system-levelRecommendation: dedicated user. Add
VPS_EMBED_USER/VPS_EMBED_SSH_PRIVATE_KEYsecrets, write.github/workflows/deploy-embedding.yamlthat rsyncs to its home and runssystemctl --user restart bibleget-embedding. The PHP deploy stays untouched in its chroot; the embedding deploy lives in a parallel lane.scripts/compute_embeddings.pyis a one-shot offline batch job — no need to ship it via either deploy. Run it from a local checkout against the prod DB when needed.Sundry findings during this work
.env.exampleis missingEMBEDDING_SERVICE_URLandCORS_ALLOWED_ORIGINS. Both are referenced insrc/but undocumented as configurable.services/andscripts/are currently still shipped by the rsync deploy — they should be excluded since the Python service is deployed by a separate lane.Suggested order of work
EMBEDDING_SERVICE_URL+CORS_ALLOWED_ORIGINSto.env.example.services/andscripts/from the rsync deploy.scripts/migrate.php, with workflow integration. No DB changes yet — just the machinery, validated against an empty schema.bibleget_dev, run MariaDB→Postgres script, apply migrations, switch /dev's.env, smoke test.v3.x.0tag → release publishes → workflow auto-deploys → migration runner provisionsbibleget_v3schema. Manual one-timepg_dump | pg_restoreofbibleget_dev → bibleget_v3to seed data.EMBEDDING_SERVICE_URLonce it's healthy.Open questions
bibleget-embeduser need network access only inbound from the chrooted PHP user (firewalled), or should it be reachable more broadly?Beta Was this translation helpful? Give feedback.
All reactions