Skip to content

fix(docker): carry migration runner + SQL in runtime image (unblocks Railway pre-deploy migrate)#149

Merged
ABB65 merged 1 commit into
mainfrom
fix/docker-predeploy-migrations
Jul 13, 2026
Merged

fix(docker): carry migration runner + SQL in runtime image (unblocks Railway pre-deploy migrate)#149
ABB65 merged 1 commit into
mainfrom
fix/docker-predeploy-migrations

Conversation

@ABB65

@ABB65 ABB65 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Problem

The Railway Pre-Deploy Command node scripts/migrate-postgres.mjs fails:

Error: Cannot find module '/app/scripts/migrate-postgres.mjs'

The runtime stage (Dockerfile Stage 3) only copies .output + .contentrain. The migration runner, the postgres/+supabase/ SQL lineage, and pg are all absent from the final image.

Fix

Copy into the runtime image:

  • scripts/migrate-postgres.mjs + scripts/verify-managed-schema.mjs
  • postgres/migrations + supabase/migrations (the lineage the runner reads)
  • a self-contained pg@8.22.0 (both scripts import only node builtins + pg; version matches the app's resolved pg)

Now the pre-deploy command applies pending migrations before the new release serves — satisfying RELEASING.md §Database and Migration Order for the managed pair on every deploy (staging + prod). Idempotent runner: already-applied migrations are no-ops.

Why this matters

Fixes the DCR/CIMD 500 root cause: 016_oauth_server (OAuth server tables) was never applied on staging because managed-pair deploys don't auto-migrate. With this, deploys self-migrate.

Validation note

Additive Dockerfile change; a bad build/pre-deploy fails the deploy fail-safe (Railway keeps the last good release). Recommend one staging redeploy to confirm the pre-deploy log shows ✓ 016_oauth_server etc., then re-test POST /oauth/register → 201.

…image

The Railway pre-deploy command `node scripts/migrate-postgres.mjs` was
failing with MODULE_NOT_FOUND — the runtime stage only copied .output and
.contentrain, so scripts/, the postgres/supabase migration SQL, and pg
were absent from /app. Copy the standalone runner + verify script + both
migration dirs, and install a self-contained pg@8.22.0 (its only
non-builtin import) so the pre-deploy command applies migrations before
each release serves.
@ABB65 ABB65 merged commit 4ea38d1 into main Jul 13, 2026
2 checks passed
@ABB65 ABB65 deleted the fix/docker-predeploy-migrations branch July 13, 2026 19:29
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.

1 participant