Drizzle migrate / push hangs against Railway Postgres via DATABASE_PUBLIC_URL; no tables are created in production
artivilla
HOBBYOP

7 days ago

Trying to initialise a production Postgres database on Railway for our backend service, but both Drizzle migration paths stall when pointed at the Railway DATABASE_PUBLIC_URL.

I'm trying to bootstrap the production schema using Drizzle from our backend workspace.

What I have already tried -

  1. Railway pre-deploy command for Drizzle migrate

cd apps/backend && ./node_modules/.bin/drizzle-kit migrate --config=drizzle.config.ts
  1. Running Drizzle migrate manually from the CLI against the Railway public Postgres URL

cd apps/backend

  SKIP_ENV_VALIDATION=true \

  DATABASE_URL='postgresql://postgres:<redacted>@junction.proxy.rlwy.net:32238/railway' \

  ./node_modules/.bin/drizzle-kit migrate --config=drizzle.config.ts
  1. Running Drizzle push manually from the CLI against the same DATABASE_PUBLIC_URL

  cd apps/backend

  SKIP_ENV_VALIDATION=true \

  DATABASE_URL='postgresql://postgres:<redacted>@junction.proxy.rlwy.net:32238/railway' \

  ./node_modules/.bin/drizzle-kit push --config=drizzle.config.ts

Observed behaviour

For migrate, the command logs:


Reading config file '/Users/artivilla/dev/github.com/artivilla/outpaint-build/apps/backend/drizzle.config.ts'

  Using 'pg' driver for database querying

  [] applying migrations...

and then stops / exits without creating tables.

For push, the command logs:


Reading config file '/Users/artivilla/dev/github.com/artivilla/outpaint-build/apps/backend/drizzle.config.ts'

  Using 'pg' driver for database querying

  [⣯] Pulling schema from database...

and then stops there.

In Railway deploy logs we also see the container reach Drizzle startup, then stop during the migration step.

Important confirmation

  • There are currently no application tables in production.
  • We have manually confirmed the production database is empty.
  • So this does not appear to be a case where existing tables from an earlier drizzle-kit push are conflicting with migration files.

Additional CLI behaviour

Running railway connect postgres gives psql: error: connection to server at "junction.proxy.rlwy.net" (...), port 32238 failed: FATAL: password authentication failed for user "postgres"

Expected behaviour

  • drizzle-kit migrate should apply the initial migration and create the schema, or
  • drizzle-kit push should create the schema directly.

Actual behaviour

  • Both commands begin database work, then hang / stop before any schema is created.
  • No tables are created in production.
Solved$10 Bounty

4 Replies

Railway
BOT

7 days ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway 7 days ago


Can you share your Postgres deployment logs?


artivilla
HOBBYOP

6 days ago

Also added a preDeployCommand to the railway.json config.


{

  "$schema": "https://railway.com/railway.schema.json",

  "build": {

    "builder": "RAILPACK",

    "buildCommand": "bun install --frozen-lockfile",

    "watchPatterns": [

      "/apps/backend/**",

      "/packages/typespecs/**",

      "/package.json",

      "/bun.lock"

    ]

  },

  "deploy": {

    "runtime": "V2",

    "numReplicas": 1,

    "preDeployCommand": "cd apps/backend && ./node_modules/.bin/drizzle-kit migrate --config=drizzle.config.ts",

    "startCommand": "bun run --cwd apps/backend src/index.ts",

    "healthcheckPath": "/health",

    "healthcheckTimeout": 300,

    "restartPolicyType": "ON_FAILURE",

    "restartPolicyMaxRetries": 10,

    "region": "us-west2"

  }

}

Deployment logs. Build was successful.

CleanShot 2026-06-21 at 15.29.56@2x.png

Attachments


artivilla
HOBBYOP

6 days ago

Got it working. There was a db source version mismatch from the underlying volume. The way I got it working is by wiping the volume. Currently I had no data so its fine. Another non related issue but as I've now upgraded to using my own source Dockerfile with FROM ghcr.io/railwayapp-templates/postgres-ssl:18.4 I noticed even though the tables do exist, I don't see the tab in the UI anymore. The second tab used to be 'Database` earlier (second image).

CleanShot 2026-06-22 at 00.11.38@2x.png

CleanShot 2026-06-21 at 16.46.19@2x.png


artivilla
HOBBYOP

8 hours ago

how do you close this ticket?


Status changed to Solved 0x5b62656e5d about 5 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...