Commit graph

10 commits

Author SHA1 Message Date
9b9b551463 feat(db): wire migration runner into the deploy pipeline
Makes schema changes deploy automatically: edit schema -> db:generate ->
commit -> push -> Dokploy redeploys -> migrations apply on container start.
No more Dokploy database terminal.

Components:
- src/db/migrate.ts: standalone migrator (single short-lived connection,
  fails loud on error so a bad migration crashes the container instead of
  letting the app serve a half-migrated schema)
- scripts/build-migrator.mjs: esbuild bundles migrate.ts -> dist/migrate.mjs
  with drizzle-orm + postgres inlined. Needed because Next.js standalone
  output keeps neither as a separate node_modules package.
- Dockerfile: builder runs db:build-migrator; runner copies migrate.mjs +
  drizzle/; CMD is 'node migrate.mjs && node server.js'
- package.json: db:generate / db:migrate / db:studio / db:pull /
  db:build-migrator scripts; esbuild promoted to an explicit devDependency
- pnpm-lock.yaml resynced

BUG FIX: .dockerignore had 'drizzle/' — migration SQL was excluded from the
build context, so even a correct Dockerfile COPY would have found nothing.
This was the second half (with the .gitignore bug in commit 1) of why the
migration pipeline never worked. Now only _archived/_introspected are
excluded.

Verified: full docker build succeeds; runner image contains migrate.mjs +
drizzle baseline; migrator tested end-to-end against a scratch DB (35
tables created, __drizzle_migrations populated, idempotent on rerun).
2026-05-23 13:40:30 +05:30
ca4e1355d6 Dockerfile: enable pnpm in builder stage 2026-05-16 22:38:02 +05:30
aec1e4bcab Dockerfile: use pnpm install --ignore-scripts to bypass build approval 2026-05-16 22:37:16 +05:30
d5a48072d7 Dockerfile: approve build scripts for esbuild/sharp 2026-05-16 22:35:58 +05:30
6f800e07df Dockerfile: use pnpm instead of npm
- Replace npm ci with pnpm install --frozen-lockfile
- Use corepack to enable pnpm
- Update COPY for pnpm-lock.yaml
2026-05-16 22:34:36 +05:30
7e2cb39d9b fix: switch to npm for docker build 2026-05-10 04:00:09 +05:30
7d50128d94 fix: use pnpm with .npmrc for docker 2026-05-10 03:58:02 +05:30
de6502fed8 fix: allow scripts in docker build 2026-05-10 03:52:42 +05:30
1706e8e509 fix: use node 22 for pnpm 11 compatibility 2026-05-10 03:51:50 +05:30
3e1dcb0866 chore: add Dockerfile and docker config 2026-05-10 03:38:03 +05:30