Upgrading
An upgrade is: pull the new code, rebuild the containers, apply any new migrations with migrate:deploy. The one step people skip is the rebuild — several containers run source directly rather than a baked artifact, so a stale image can silently keep running old code.
Only one of these two commands is supported in this repo.
How to upgrade
- Pull the new version of the repository (
git pull, or check out the release tag you want). - Rebuild the images —
docker compose buildsoapi,web, andworkerpick up the new source, thenpnpm installif dependencies changed. Usebuild, notup -d --build— the latter starts the new code immediately, ahead of the migrations below. - Apply Postgres migrations —
pnpm --filter @deckgauge/db migrate:deploy. This only applies migrations that haven't run yet; it's safe to run on every upgrade, whether or not the schema changed. - Apply ClickHouse schema changes —
pnpm migrate:clickhouse. New widgets add tables underclickhouse/schemas/; skip this and the first render of such a widget throws an unknown-table error instead of a clean empty state. Every schema file usesIF NOT EXISTS, so it's safe to run on every upgrade too. - Bring the stack back up —
docker compose up -d.
Why migrate:dev doesn't work here
pnpm --filter @deckgauge/db migrate:dev fails with a shadow-database error (Prisma error P3006) in this repository — it isn't a supported path for either local development or an upgrade. migrate:deploy is: it applies whatever migrations are already committed under packages/db/prisma/migrations/ without needing a shadow database at all. If you're the one adding a new migration rather than applying existing ones, hand-write the migration SQL yourself and apply it the same way with migrate:deploy.
The rebuild story
worker isn't the odd one out here — api runs the same way. Both containers' CMD is npx tsx src/index.ts: they run their TypeScript source directly, not a compiled dist/ build. The one container that's a genuinely compiled artifact is web — its Dockerfile runs a Next.js build and ships the standalone output, so its CMD is node apps/web/server.js, no tsx involved. That distinction doesn't change what an upgrade needs, though: all three images bake their code in at build time, so a plain docker compose restart worker (or api, or web) after a code change does nothing regardless of which one you touched — the container is still running whatever was copied in during its last docker compose build. An upgrade that touches any of their code needs an actual rebuild — docker compose build worker api web (or --no-cache if you suspect a stale layer) — before restarting the affected service(s).
If it looks wrong
| Symptom | Cause | Fix |
|---|---|---|
migrate:dev fails with a shadow-database error (P3006) | It isn't supported in this repo | Use migrate:deploy instead; hand-write new migration SQL if you're authoring one |
| Worker behavior didn't change after an upgrade | The container is still running its previous build | Rebuild the worker image explicitly, then restart it |
| A new widget throws an unknown-table error | The ClickHouse schema step was skipped | Run pnpm migrate:clickhouse |
migrate:deploy fails partway through | Postgres isn't reachable, or a prior migration left the schema in an unexpected state | Confirm postgres is healthy first; see Troubleshooting for connectivity failure modes |
Related
- Backup & restore — take a backup before any upgrade that touches the schema.
- Install & first run — the same
migrate:deploystep, on a fresh install. - Services & architecture — how
api,web, andworkerare built.
Last updated