fix(docker): carry migration runner + SQL in runtime image (unblocks Railway pre-deploy migrate)#149
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Railway Pre-Deploy Command
node scripts/migrate-postgres.mjsfails:The runtime stage (Dockerfile Stage 3) only copies
.output+.contentrain. The migration runner, thepostgres/+supabase/SQL lineage, andpgare all absent from the final image.Fix
Copy into the runtime image:
scripts/migrate-postgres.mjs+scripts/verify-managed-schema.mjspostgres/migrations+supabase/migrations(the lineage the runner reads)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_serveretc., then re-testPOST /oauth/register→ 201.