# Deploy it

URL: https://kywi-docs-production.up.railway.app/start/deploy-it
Type: docPage

Deploying a Kywi app is a Next build plus a Postgres, with one rule — migrations are run by hand, never as a pre-deploy hook.

A Kywi deploy is an ordinary Next build and start against a Postgres database — there is no separate Kywi runtime to install. Set the start command explicitly rather than trusting the platform's default: on Railway, no start command left Railpack running `pnpm start`, and pnpm treats a child process ended by `SIGTERM` as a failed script and exits 1 — so every deploy reported a crash on the otherwise-healthy container it was replacing. The fix was a literal `node_modules/.bin/next start`.

## Two environment variables the app refuses to boot without

`DATABASE_URL` and `AUTH_SECRET` both have to be set before the app will start in production — it refuses to boot without either one, and this project's own first deploy failed on `AUTH_SECRET`, before the variable existed. Surface 8 covers the full environment, four variables in total; see [Deploying a host app](/operating/deploying-a-host-app/) for the other two, and [AUTH_SECRET and the production fail-fast](/operating/authsecret-and-production-fail-fast/) for what the failure looks like.

## Migrations are never a pre-deploy hook

## Never wire a migration into a deploy hook

Run migrations by hand, before you push: take a `pg_dump`, run `kywi migrate` against the database yourself, then push the code that depends on the new schema. A plain `kywi migrate` no longer hangs on an ambiguous change — it exits 1 with an actionable message instead of prompting. The rule exists because of what running it as a pre-deploy hook used to do: with `--push` wired in as that hook, an interactive prompt with no terminal to answer it hung one of this project's own Railway deployments forever, blocking every deploy behind it until it was cancelled through the platform API. `--push` is now refused outright once a project has a migration journal — but the standing rule is the same either way: nothing that touches schema belongs in a deploy hook.

One more thing that catches people out on the same platform: a redeploy re-uses the previous deployment's frozen settings, so it will re-run a pre-deploy hook you have since removed from the service configuration. After changing service settings, trigger a fresh source deploy — or push a commit — instead of redeploying the old one.

## Where the rest of this lives

Surface 8 owns every one of these in full, in the operator's register: [Deploying a host app](/operating/deploying-a-host-app/), [Running migrations against a live database](/operating/running-migrations-against-a-live-database/), [Why drizzle-kit push is banned before deploy](/operating/why-drizzle-kit-push-is-banned-before-deploy/), and [Backups: what Kywi does not do for you](/operating/backups-what-kywi-does-not-do-for-you/).

The specifics above — the start-command fix, the cancelled deployment, the frozen-settings redeploy — describe Railway, the one platform this project has actually deployed to and verified. Nothing here claims to generalize to another host.
